Ver código fonte

加工单账单完成

jz.kai 1 ano atrás
pai
commit
90d46d55b6

+ 3 - 0
common/src/main/java/com/jpsoft/printing/modules/base/dao/AccountDAO.java

@@ -1,5 +1,6 @@
 package com.jpsoft.printing.modules.base.dao;
 
+import java.math.BigDecimal;
 import java.util.List;
 import org.springframework.stereotype.Repository;
 import com.jpsoft.printing.modules.base.entity.Account;
@@ -15,4 +16,6 @@ public interface AccountDAO {
 	int delete(String id);
 	List<Account> list();
 	List<Account> search(Map<String,Object> searchParams,List<Sort> sortList);
+	BigDecimal getBalance(String customerId, String deadline);
+	Account getByWorkId(String workId);
 }

+ 8 - 6
common/src/main/java/com/jpsoft/printing/modules/base/entity/Account.java

@@ -26,12 +26,14 @@ public class Account {
     private Integer type;
         @ApiModelProperty(value = "计划单号")
     private String planNumber;
-        @ApiModelProperty(value = "摘要")
-    private String summary;
-        @ApiModelProperty(value = "金额")
-    private BigDecimal amount;
-        @ApiModelProperty(value = "余额")
-    private BigDecimal balance;
+        @ApiModelProperty(value = "实数金额")
+    private BigDecimal actualAmount;
+        @ApiModelProperty(value = "坯布金额")
+    private BigDecimal clothAmount;
+        @ApiModelProperty(value = "力工金额")
+    private BigDecimal rollAmount;
+        @ApiModelProperty(value = "总金额")
+    private BigDecimal totalAmount;
         @ApiModelProperty(value = "删除标示")
     private Boolean delFlag;
         @ApiModelProperty(value = "创建人")

+ 2 - 0
common/src/main/java/com/jpsoft/printing/modules/base/entity/Work.java

@@ -78,4 +78,6 @@ public class Work {
     private BigDecimal rollAmount;
     @ApiModelProperty(value = "合计金额")
     private BigDecimal totalAmount;
+    @ApiModelProperty(value = "有无账单")
+    private Boolean haveBills;
 }

+ 3 - 0
common/src/main/java/com/jpsoft/printing/modules/base/service/AccountService.java

@@ -1,5 +1,6 @@
 package com.jpsoft.printing.modules.base.service;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 import com.jpsoft.printing.modules.base.entity.Account;
@@ -14,4 +15,6 @@ public interface AccountService {
 	int delete(String id);
 	List<Account> list();
 	Page<Account> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+	BigDecimal getBalance(String customerId, String deadline);
+	Account getByWorkId(String workId);
 }

+ 11 - 0
common/src/main/java/com/jpsoft/printing/modules/base/service/impl/AccountServiceImpl.java

@@ -1,5 +1,6 @@
 package com.jpsoft.printing.modules.base.service.impl;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -67,4 +68,14 @@ public class AccountServiceImpl implements AccountService {
         
         return page;
 	}
+
+	@Override
+	public BigDecimal getBalance(String customerId, String deadline) {
+		return accountDAO.getBalance(customerId, deadline);
+	}
+
+	@Override
+	public Account getByWorkId(String workId) {
+		return accountDAO.getByWorkId(workId);
+	}
 }

+ 31 - 14
common/src/main/resources/mapper/base/Account.xml

@@ -9,9 +9,10 @@
 			<result property="workId" column="work_id" />
 			<result property="type" column="type_" />
 			<result property="planNumber" column="plan_number" />
-			<result property="summary" column="summary_" />
-			<result property="amount" column="amount_" />
-			<result property="balance" column="balance_" />
+			<result property="actualAmount" column="actual_amount" />
+			<result property="clothAmount" column="cloth_amount" />
+			<result property="rollAmount" column="roll_amount" />
+			<result property="totalAmount" column="total_amount" />
 			<result property="delFlag" column="del_flag" />
 			<result property="createBy" column="create_by" />
 			<result property="createTime" column="create_time" />
@@ -26,7 +27,7 @@
 	-->
 	<![CDATA[
 		insert into base_account
-	    (id_,customer_id,work_id,type_,plan_number,summary_,amount_,balance_,del_flag,create_by,create_time,update_by,update_time)
+	    (id_,customer_id,work_id,type_,plan_number,actual_amount,cloth_amount,roll_amount,total_amount,del_flag,create_by,create_time,update_by,update_time)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -34,9 +35,10 @@
 ,#{workId,jdbcType=VARCHAR}
 ,#{type,jdbcType= NUMERIC }
 ,#{planNumber,jdbcType=VARCHAR}
-,#{summary,jdbcType=VARCHAR}
-,#{amount,jdbcType= NUMERIC }
-,#{balance,jdbcType= NUMERIC }
+,#{actualAmount,jdbcType= NUMERIC }
+,#{clothAmount,jdbcType= NUMERIC }
+,#{rollAmount,jdbcType= NUMERIC }
+,#{totalAmount,jdbcType= NUMERIC }
 ,#{delFlag,jdbcType= NUMERIC }
 ,#{createBy,jdbcType=VARCHAR}
 ,#{createTime,jdbcType= TIMESTAMP }
@@ -63,14 +65,17 @@
 				<if test="planNumber!=null">
 		plan_number=#{planNumber,jdbcType=VARCHAR},
 		</if>
-				<if test="summary!=null">
-		summary_=#{summary,jdbcType=VARCHAR},
+				<if test="actualAmount!=null">
+		actual_amount=#{actualAmount,jdbcType= NUMERIC },
 		</if>
-				<if test="amount!=null">
-		amount_=#{amount,jdbcType= NUMERIC },
+				<if test="clothAmount!=null">
+		cloth_amount=#{clothAmount,jdbcType= NUMERIC },
 		</if>
-				<if test="balance!=null">
-		balance_=#{balance,jdbcType= NUMERIC },
+				<if test="rollAmount!=null">
+		roll_amount=#{rollAmount,jdbcType= NUMERIC },
+		</if>
+				<if test="totalAmount!=null">
+		total_amount=#{totalAmount,jdbcType= NUMERIC },
 		</if>
 				<if test="delFlag!=null">
 		del_flag=#{delFlag,jdbcType= NUMERIC },
@@ -92,7 +97,7 @@
 	</update>
 	<select id="get" parameterType="string" resultMap="AccountMap">
 		select 
-id_,customer_id,work_id,type_,plan_number,summary_,amount_,balance_,del_flag,create_by,create_time,update_by,update_time		from base_account where id_=#{0}
+id_,customer_id,work_id,type_,plan_number,actual_amount,cloth_amount,roll_amount,total_amount,del_flag,create_by,create_time,update_by,update_time		from base_account where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_account where id_=#{0}
@@ -113,4 +118,16 @@ id_,customer_id,work_id,type_,plan_number,summary_,amount_,balance_,del_flag,cre
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="getBalance" parameterType="string" resultType="int">
+		<![CDATA[
+			SELECT SUM(amount_) FROM base_account
+			WHERE del_flag = 0
+			AND customer_id = #{customerId}
+			AND create_time <= CONCAT(#{deadline},' 23:59:59')
+		]]>
+	</select>
+	<select id="getByWorkId" parameterType="string" resultMap="AccountMap">
+		select * from base_account
+		where work_id = #{0}
+	</select>
 </mapper>

+ 48 - 0
web/src/main/java/com/jpsoft/printing/modules/base/controller/AccountController.java

@@ -183,4 +183,52 @@ public class AccountController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="生成账单")
+    @PostMapping("addBill")
+    @Transactional(rollbackFor = Exception.class)
+    public MessageResult<Account> addBill(String workId, BigDecimal amount, BigDecimal actualAmount, BigDecimal clothAmount, BigDecimal rollAmount, @RequestAttribute String subject,HttpServletRequest request){
+        Long begin = System.currentTimeMillis();
+        MessageResult<Account> msgResult = new MessageResult<>();
+
+        try {
+            Work work = workService.get(workId);
+
+            Account account = new Account();
+            account.setId(UUID.randomUUID().toString());
+            account.setCustomerId(work.getCustomerId());
+            account.setWorkId(workId);
+            account.setType(0);
+            account.setPlanNumber(work.getNumber());
+            account.setActualAmount(actualAmount);
+            account.setClothAmount(clothAmount);
+            account.setRollAmount(rollAmount);
+            account.setTotalAmount(amount);
+            account.setDelFlag(false);
+            account.setCreateBy(subject);
+            account.setCreateTime(new Date());
+
+            int affectCount = accountService.insert(account);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(account);
+                msgResult.setMessage("数据库添加成功");
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+
+            Long end = System.currentTimeMillis();
+            sysLogService.addLog(subject,request.getRemoteAddr(),request.getServletPath(),account.toString(),end-begin,null,msgResult.getMessage());
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 12 - 2
web/src/main/java/com/jpsoft/printing/modules/base/controller/WorkController.java

@@ -1,7 +1,9 @@
 package com.jpsoft.printing.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.jpsoft.printing.modules.base.entity.Account;
 import com.jpsoft.printing.modules.base.entity.Customer;
+import com.jpsoft.printing.modules.base.service.AccountService;
 import com.jpsoft.printing.modules.base.service.CustomerService;
 import com.jpsoft.printing.modules.common.utils.PojoUtils;
 import com.jpsoft.printing.modules.common.dto.Sort;
@@ -33,6 +35,8 @@ public class WorkController {
     private CustomerService customerService;
     @Autowired
     private WorkService workService;
+    @Autowired
+    private AccountService accountService;
 
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
@@ -251,15 +255,21 @@ public class WorkController {
         for(Work work : page.getResult()){
             Customer customer = customerService.get(work.getCustomerId());
             String allName = "";
-
             if(StringUtils.isNotEmpty(customer.getCompany())){
                 allName = customer.getName() + "(" + customer.getCompany() + ")";
             }
             else{
                 allName = customer.getName();
             }
-
             work.setCustomerName(allName);
+
+            Account account = accountService.getByWorkId(work.getId());
+            if(account != null){
+                work.setHaveBills(true);
+            }
+            else{
+                work.setHaveBills(false);
+            }
         }
 
         msgResult.setResult(true);