浏览代码

进账账单完成

jz.kai 1 年之前
父节点
当前提交
a3ca1f026c

+ 1 - 0
common/src/main/java/com/jpsoft/printing/modules/base/entity/Account.java

@@ -20,6 +20,7 @@ public class Account {
     private String id;
         @ApiModelProperty(value = "客户编号")
     private String customerId;
+    private String customerName;
         @ApiModelProperty(value = "工单编号")
     private String workId;
         @ApiModelProperty(value = "类型(0-订单 1-收款 2-冲账)")

+ 23 - 16
common/src/main/resources/mapper/base/Account.xml

@@ -5,20 +5,20 @@
 <mapper namespace="com.jpsoft.printing.modules.base.dao.AccountDAO">
 	<resultMap id="AccountMap" type="com.jpsoft.printing.modules.base.entity.Account">
 		<id property="id" column="id_" />
-			<result property="customerId" column="customer_id" />
-			<result property="workId" column="work_id" />
-			<result property="type" column="type_" />
-			<result property="planNumber" column="plan_number" />
-			<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" />
-			<result property="updateBy" column="update_by" />
-			<result property="updateTime" column="update_time" />
-			</resultMap>
+		<result property="customerId" column="customer_id" />
+		<result property="workId" column="work_id" />
+		<result property="type" column="type_" />
+		<result property="planNumber" column="plan_number" />
+		<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" />
+		<result property="updateBy" column="update_by" />
+		<result property="updateTime" column="update_time" />
+	</resultMap>
 	<insert id="insert" parameterType="com.jpsoft.printing.modules.base.entity.Account">
 	<!--
 	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
@@ -110,8 +110,15 @@ id_,customer_id,work_id,type_,plan_number,actual_amount,cloth_amount,roll_amount
 			select * from base_account
 		]]>
 		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+			del_flag = 0
+			<if test="searchParams.type != null">
+				and type_ = #{searchParams.type}
+			</if>
+			<if test="searchParams.customerId != null">
+				and customer_id = #{searchParams.customerId}
+			</if>
+			<if test="searchParams.planNumber != null">
+				and plan_number like #{searchParams.planNumber}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 71 - 4
web/src/main/java/com/jpsoft/printing/modules/base/controller/AccountController.java

@@ -42,6 +42,56 @@ public class AccountController {
     @Autowired
     private AccountService accountService;
 
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<Account> create(){
+        MessageResult<Account> msgResult = new MessageResult<>();
+
+        Account account = new Account();
+
+        msgResult.setData(account);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    @Transactional(rollbackFor = Exception.class)
+    public MessageResult<Account> add(@RequestBody Account account,@RequestAttribute String subject,HttpServletRequest request){
+        Long begin = System.currentTimeMillis();
+        MessageResult<Account> msgResult = new MessageResult<>();
+
+        try {
+            account.setId(UUID.randomUUID().toString());
+            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;
+    }
+
     @ApiOperation(value="获取信息")
     @GetMapping("edit/{id}")
     public MessageResult edit(@PathVariable("id") String id){
@@ -106,21 +156,38 @@ public class AccountController {
     @ApiOperation(value="列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
-            String id,
+            String type, String customerId, String planNumber,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
         MessageResult<Map> msgResult = new MessageResult<>();
 
         Map<String,Object> searchParams = new HashMap<>();
-		if (StringUtils.isNotEmpty(id)) {
-            searchParams.put("id","%" + id + "%");
+		if (StringUtils.isNotEmpty(type)) {
+            searchParams.put("type",type);
+        }
+        if (StringUtils.isNotEmpty(customerId)) {
+            searchParams.put("customerId",customerId);
+        }
+        if (StringUtils.isNotEmpty(planNumber)) {
+            searchParams.put("planNumber","%" + planNumber + "%");
         }
 
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("id_","asc"));
 
         Page<Account> page = accountService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+        for(Account account : page.getResult()) {
+            Customer customer = customerService.get(account.getCustomerId());
+            String allName = "";
+            if(StringUtils.isNotEmpty(customer.getCompany())){
+                allName = customer.getName() + "(" + customer.getCompany() + ")";
+            }
+            else{
+                allName = customer.getName();
+            }
+            account.setCustomerName(allName);
+        }
 
         msgResult.setResult(true);
         msgResult.setData(PojoUtils.pageWrapper(page));
@@ -203,7 +270,7 @@ public class AccountController {
             account.setActualAmount(actualAmount);
             account.setClothAmount(clothAmount);
             account.setRollAmount(rollAmount);
-            account.setTotalAmount(amount);
+            account.setTotalAmount(amount.negate());
             account.setDelFlag(false);
             account.setCreateBy(subject);
             account.setCreateTime(new Date());