jz.kai 5 år sedan
förälder
incheckning
f9b3c3c434

+ 19 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/dao/CompanyInvoiceDAO.java

@@ -0,0 +1,19 @@
+package com.jpsoft.picc.modules.base.dao;
+
+import java.util.List;
+import org.springframework.stereotype.Repository;
+import com.jpsoft.picc.modules.base.entity.CompanyInvoice;
+import java.util.Map;
+import com.jpsoft.picc.modules.common.dto.Sort;
+
+@Repository
+public interface CompanyInvoiceDAO {
+	int insert(CompanyInvoice entity);
+	int update(CompanyInvoice entity);
+	int exist(String id);
+	CompanyInvoice get(String id);
+	int delete(String id);
+	List<CompanyInvoice> list();
+	List<CompanyInvoice> search(Map<String, Object> searchParams, List<Sort> sortList);
+	CompanyInvoice getByCompanyId(String id);
+}

+ 98 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/entity/CompanyInvoice.java

@@ -0,0 +1,98 @@
+package com.jpsoft.picc.modules.base.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+import org.springframework.format.annotation.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+  描述:base_company_invoice的实体类
+ */
+@Data
+@ApiModel(value = "base_company_invoice的实体类")
+public class CompanyInvoice {
+	/**
+	 *ID
+	 */
+        @ApiModelProperty(value = "ID")
+	private String id;
+	/**
+	 *企业编号
+	 */
+        @ApiModelProperty(value = "企业编号")
+	private String companyId;
+	/**
+	 *发票类型
+	 */
+        @ApiModelProperty(value = "发票类型")
+	private String type;
+	/**
+	 *发票抬头
+	 */
+        @ApiModelProperty(value = "发票抬头")
+	private String title;
+	/**
+	 *税号
+	 */
+        @ApiModelProperty(value = "税号")
+	private String identifier;
+	/**
+	 *开户银行
+	 */
+        @ApiModelProperty(value = "开户银行")
+	private String bank;
+	/**
+	 *企业账号
+	 */
+        @ApiModelProperty(value = "企业账号")
+	private String companyAccount;
+	/**
+	 *联行号
+	 */
+        @ApiModelProperty(value = "联行号")
+	private String bankAccount;
+	/**
+	 *企业地址
+	 */
+        @ApiModelProperty(value = "企业地址")
+	private String address;
+	/**
+	 *联系电话
+	 */
+        @ApiModelProperty(value = "联系电话")
+	private String telephone;
+	/**
+	 *是否删除
+	 */
+        @ApiModelProperty(value = "是否删除")
+	private Boolean delFlag;
+	/**
+	 *创建人
+	 */
+        @ApiModelProperty(value = "创建人")
+	private String createBy;
+	/**
+	 *创建时间
+	 */
+    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**
+	 *更新人
+	 */
+        @ApiModelProperty(value = "更新人")
+	private String updateBy;
+	/**
+	 *更新时间
+	 */
+    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "更新时间")
+	private Date updateTime;
+}

+ 18 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/CompanyInvoiceService.java

@@ -0,0 +1,18 @@
+package com.jpsoft.picc.modules.base.service;
+
+import java.util.List;
+import java.util.Map;
+import com.jpsoft.picc.modules.base.entity.CompanyInvoice;
+import com.github.pagehelper.Page;
+import com.jpsoft.picc.modules.common.dto.Sort;
+
+public interface CompanyInvoiceService {
+	CompanyInvoice get(String id);
+	boolean exist(String id);
+	int insert(CompanyInvoice model);
+	int update(CompanyInvoice model);
+	int delete(String id);
+	List<CompanyInvoice> list();
+	Page<CompanyInvoice> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+	CompanyInvoice getByCompanyId(String id);
+}

+ 76 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/impl/CompanyInvoiceServiceImpl.java

@@ -0,0 +1,76 @@
+package com.jpsoft.picc.modules.base.service.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.picc.modules.base.dao.CompanyInvoiceDAO;
+import com.jpsoft.picc.modules.base.entity.CompanyInvoice;
+import com.jpsoft.picc.modules.base.service.CompanyInvoiceService;
+import com.github.pagehelper.Page;
+import com.jpsoft.picc.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="companyInvoiceService")
+public class CompanyInvoiceServiceImpl implements CompanyInvoiceService {
+	@Resource(name="companyInvoiceDAO")
+	private CompanyInvoiceDAO companyInvoiceDAO;
+
+	@Override
+	public CompanyInvoice get(String id) {
+		// TODO Auto-generated method stub
+		return companyInvoiceDAO.get(id);
+	}
+
+	@Override
+	public int insert(CompanyInvoice model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return companyInvoiceDAO.insert(model);
+	}
+
+	@Override
+	public int update(CompanyInvoice model) {
+		// TODO Auto-generated method stub
+		return companyInvoiceDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return companyInvoiceDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = companyInvoiceDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<CompanyInvoice> list() {
+		// TODO Auto-generated method stub
+		return companyInvoiceDAO.list();
+	}
+		
+	@Override
+	public Page<CompanyInvoice> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<CompanyInvoice> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            companyInvoiceDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+
+	@Override
+	public CompanyInvoice getByCompanyId(String id) {
+		// TODO Auto-generated method stub
+		return companyInvoiceDAO.getByCompanyId(id);
+	}
+}

+ 130 - 0
picc-common/src/main/resources/mapper/base/CompanyInvoice.xml

@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.picc.modules.base.dao.CompanyInvoiceDAO">
+	<resultMap id="CompanyInvoiceMap" type="com.jpsoft.picc.modules.base.entity.CompanyInvoice">
+		<id property="id" column="id_" />
+			<result property="companyId" column="company_id" />
+			<result property="type" column="type_" />
+			<result property="title" column="title_" />
+			<result property="identifier" column="identifier_" />
+			<result property="bank" column="bank_" />
+			<result property="companyAccount" column="company_account" />
+			<result property="bankAccount" column="bank_account" />
+			<result property="address" column="address_" />
+			<result property="telephone" column="telephone_" />
+			<result property="delFlag" column="del_flag" />
+			<result property="createBy" column="create_by" />
+			<result property="createTime" column="create_time" />
+			<result property="updateBy" column="update_by" />
+			<result property="updateTime" column="update_time" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.picc.modules.base.entity.CompanyInvoice">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_company_invoice
+	    (id_,company_id,type_,title_,identifier_,bank_,company_account,bank_account,address_,telephone_,del_flag,create_by,create_time,update_by,update_time)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{companyId,jdbcType=VARCHAR}
+,#{type,jdbcType=VARCHAR}
+,#{title,jdbcType=VARCHAR}
+,#{identifier,jdbcType=VARCHAR}
+,#{bank,jdbcType=VARCHAR}
+,#{companyAccount,jdbcType=VARCHAR}
+,#{bankAccount,jdbcType=VARCHAR}
+,#{address,jdbcType=VARCHAR}
+,#{telephone,jdbcType=VARCHAR}
+,#{delFlag,jdbcType= NUMERIC }
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_company_invoice where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.picc.modules.base.entity.CompanyInvoice">
+		update base_company_invoice
+		<set>
+				<if test="companyId!=null">
+		company_id=#{companyId,jdbcType=VARCHAR},
+		</if>
+				<if test="type!=null">
+		type_=#{type,jdbcType=VARCHAR},
+		</if>
+				<if test="title!=null">
+		title_=#{title,jdbcType=VARCHAR},
+		</if>
+				<if test="identifier!=null">
+		identifier_=#{identifier,jdbcType=VARCHAR},
+		</if>
+				<if test="bank!=null">
+		bank_=#{bank,jdbcType=VARCHAR},
+		</if>
+				<if test="companyAccount!=null">
+		company_account=#{companyAccount,jdbcType=VARCHAR},
+		</if>
+				<if test="bankAccount!=null">
+		bank_account=#{bankAccount,jdbcType=VARCHAR},
+		</if>
+				<if test="address!=null">
+		address_=#{address,jdbcType=VARCHAR},
+		</if>
+				<if test="telephone!=null">
+		telephone_=#{telephone,jdbcType=VARCHAR},
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</if>
+				<if test="createBy!=null">
+		create_by=#{createBy,jdbcType=VARCHAR},
+		</if>
+				<if test="createTime!=null">
+		create_time=#{createTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="updateBy!=null">
+		update_by=#{updateBy,jdbcType=VARCHAR},
+		</if>
+				<if test="updateTime!=null">
+		update_time=#{updateTime,jdbcType= TIMESTAMP },
+		</if>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="CompanyInvoiceMap">
+		select 
+id_,company_id,type_,title_,identifier_,bank_,company_account,bank_account,address_,telephone_,del_flag,create_by,create_time,update_by,update_time		from base_company_invoice where id_=#{0}
+	</select>
+	<select id="getByCompanyId" parameterType="string" resultMap="CompanyInvoiceMap">
+		select id_,company_id,type_,title_,identifier_,bank_,company_account,bank_account,address_,telephone_,del_flag,create_by,create_time,update_by,update_time from base_company_invoice
+		where company_id=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_company_invoice where id_=#{0}
+	</select>
+	<select id="list" resultMap="CompanyInvoiceMap">
+		select * from base_company_invoice
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="CompanyInvoiceMap">
+		<![CDATA[
+			select * from base_company_invoice
+		]]>
+		<where>
+			<if test="searchParams.id != null">
+				and ID_ like #{searchParams.id}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+</mapper>

+ 96 - 0
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/CompanyInvoiceController.java

@@ -0,0 +1,96 @@
+package com.jpsoft.picc.modules.auth.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.picc.modules.base.entity.Company;
+import com.jpsoft.picc.modules.base.entity.CompanyUser;
+import com.jpsoft.picc.modules.base.service.CompanyService;
+import com.jpsoft.picc.modules.base.service.CompanyUserService;
+import com.jpsoft.picc.modules.common.dto.Sort;
+import com.jpsoft.picc.modules.common.utils.PojoUtils;
+import com.jpsoft.picc.modules.common.dto.MessageResult;
+import com.jpsoft.picc.modules.base.entity.CompanyInvoice;
+import com.jpsoft.picc.modules.base.service.CompanyInvoiceService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.jasig.cas.client.authentication.AttributePrincipal;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/companyInvoice")
+@Api(description = "companyInvoice")
+public class CompanyInvoiceController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private CompanyService companyService;
+    @Autowired
+    private CompanyUserService companyUserService;
+    @Autowired
+    private CompanyInvoiceService companyInvoiceService;
+
+    @GetMapping(value="detail")
+    @ApiOperation(value = "获取发票信息")
+    public MessageResult<CompanyInvoice> detail(HttpServletRequest request){
+        MessageResult<CompanyInvoice> messageResult = new MessageResult<>();
+
+        try {
+            //todo
+            AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
+            CompanyUser companyUser = companyUserService.findByUserName(principal.getName());
+            CompanyInvoice companyInvoice = companyInvoiceService.getByCompanyId(companyUser.getCompanyId());
+
+            if(companyInvoice == null) {
+                companyInvoice = new CompanyInvoice();
+            }
+
+            messageResult.setResult(true);
+            messageResult.setData(companyInvoice);
+        }
+        catch (Exception ex){
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping(value="save")
+    @ApiOperation(value = "保存发票信息")
+    public MessageResult<String> save(CompanyInvoice companyInvoice,HttpServletRequest request){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            //todo
+            AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
+            CompanyUser companyUser = companyUserService.findByUserName(principal.getName());
+
+            if(StringUtils.isNotEmpty(companyInvoice.getId())){
+                companyInvoice.setUpdateBy(principal.getName());
+                companyInvoice.setUpdateTime(new Date());
+                companyInvoiceService.update(companyInvoice);
+            }else{
+                companyInvoice.setCompanyId(companyUser.getCompanyId());
+                companyInvoice.setDelFlag(false);
+                companyInvoice.setCreateBy(principal.getName());
+                companyInvoice.setCreateTime(new Date());
+                companyInvoiceService.insert(companyInvoice);
+            }
+
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+}