浏览代码

账单显示

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

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

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

+ 3 - 0
common/src/main/java/com/jpsoft/printing/modules/base/dao/StockDAO.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.Stock;
@@ -15,4 +16,6 @@ public interface StockDAO {
 	int delete(String id);
 	List<Stock> list();
 	List<Stock> search(Map<String,Object> searchParams,List<Sort> sortList);
+	BigDecimal getActualQuantity(String workId);
+	BigDecimal getRollQuantity(String workId);
 }

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

@@ -0,0 +1,49 @@
+package com.jpsoft.printing.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_account的实体类
+ */
+@Data
+@ApiModel(value = "base_account的实体类")
+public class Account {
+        @ApiModelProperty(value = "ID")
+    private String id;
+        @ApiModelProperty(value = "客户编号")
+    private String customerId;
+        @ApiModelProperty(value = "工单编号")
+    private String workId;
+        @ApiModelProperty(value = "类型(0-订单 1-收款 2-冲账)")
+    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 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;
+}

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

@@ -63,4 +63,19 @@ public class Work {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
 	    @ApiModelProperty(value = "更新时间")
     private Date updateTime;
+
+    @ApiModelProperty(value = "实交成品数")
+    private BigDecimal actualQuantity;
+    @ApiModelProperty(value = "实交成品金额")
+    private BigDecimal actualAmount;
+    @ApiModelProperty(value = "坯布数")
+    private BigDecimal clothQuantity;
+    @ApiModelProperty(value = "坯布金额")
+    private BigDecimal clothAmount;
+    @ApiModelProperty(value = "卷数")
+    private BigDecimal rollQuantity;
+    @ApiModelProperty(value = "卷金额")
+    private BigDecimal rollAmount;
+    @ApiModelProperty(value = "合计金额")
+    private BigDecimal totalAmount;
 }

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

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

+ 3 - 0
common/src/main/java/com/jpsoft/printing/modules/base/service/StockService.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.Stock;
@@ -14,4 +15,6 @@ public interface StockService {
 	int delete(String id);
 	List<Stock> list();
 	Page<Stock> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+	BigDecimal getActualQuantity(String workId);
+	BigDecimal getRollQuantity(String workId);
 }

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

@@ -0,0 +1,70 @@
+package com.jpsoft.printing.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.printing.modules.base.dao.AccountDAO;
+import com.jpsoft.printing.modules.base.entity.Account;
+import com.jpsoft.printing.modules.base.service.AccountService;
+import com.github.pagehelper.Page;
+import com.jpsoft.printing.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="accountService")
+public class AccountServiceImpl implements AccountService {
+	@Resource(name="accountDAO")
+	private AccountDAO accountDAO;
+
+	@Override
+	public Account get(String id) {
+		// TODO Auto-generated method stub
+		return accountDAO.get(id);
+	}
+
+	@Override
+	public int insert(Account model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return accountDAO.insert(model);
+	}
+
+	@Override
+	public int update(Account model) {
+		// TODO Auto-generated method stub
+		return accountDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return accountDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = accountDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<Account> list() {
+		// TODO Auto-generated method stub
+		return accountDAO.list();
+	}
+		
+	@Override
+	public Page<Account> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<Account> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            accountDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+}

+ 12 - 0
common/src/main/java/com/jpsoft/printing/modules/base/service/impl/StockServiceImpl.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,15 @@ public class StockServiceImpl implements StockService {
         
         return page;
 	}
+
+	@Override
+	public BigDecimal getActualQuantity(String workId) {
+		BigDecimal sum = stockDAO.getActualQuantity(workId);
+		return sum;
+	}
+
+	@Override
+	public BigDecimal getRollQuantity(String workId) {
+		return stockDAO.getRollQuantity(workId);
+	}
 }

+ 116 - 0
common/src/main/resources/mapper/base/Account.xml

@@ -0,0 +1,116 @@
+<?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.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="summary" column="summary_" />
+			<result property="amount" column="amount_" />
+			<result property="balance" column="balance_" />
+			<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">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![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)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{customerId,jdbcType=VARCHAR}
+,#{workId,jdbcType=VARCHAR}
+,#{type,jdbcType= NUMERIC }
+,#{planNumber,jdbcType=VARCHAR}
+,#{summary,jdbcType=VARCHAR}
+,#{amount,jdbcType= NUMERIC }
+,#{balance,jdbcType= NUMERIC }
+,#{delFlag,jdbcType= NUMERIC }
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_account where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.printing.modules.base.entity.Account">
+		update base_account
+		<set>
+				<if test="customerId!=null">
+		customer_id=#{customerId,jdbcType=VARCHAR},
+		</if>
+				<if test="workId!=null">
+		work_id=#{workId,jdbcType=VARCHAR},
+		</if>
+				<if test="type!=null">
+		type_=#{type,jdbcType= NUMERIC },
+		</if>
+				<if test="planNumber!=null">
+		plan_number=#{planNumber,jdbcType=VARCHAR},
+		</if>
+				<if test="summary!=null">
+		summary_=#{summary,jdbcType=VARCHAR},
+		</if>
+				<if test="amount!=null">
+		amount_=#{amount,jdbcType= NUMERIC },
+		</if>
+				<if test="balance!=null">
+		balance_=#{balance,jdbcType= NUMERIC },
+		</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="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}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_account where id_=#{0}
+	</select>
+	<select id="list" resultMap="AccountMap">
+		select * from base_account
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="AccountMap">
+		<![CDATA[
+			select * from base_account
+		]]>
+		<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>

+ 10 - 0
common/src/main/resources/mapper/base/Stock.xml

@@ -105,4 +105,14 @@ id_,work_id,length_,flaw_,status_,del_flag,create_by,create_time,update_by,updat
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="getActualQuantity" parameterType="string" resultType="decimal">
+		select sum(length_) from base_stock
+		where del_flag = 0
+		and work_id = #{0}
+	</select>
+	<select id="getRollQuantity" parameterType="string" resultType="decimal">
+		select count(id_) from base_stock
+		where del_flag = 0
+		and work_id = #{0}
+	</select>
 </mapper>

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

@@ -0,0 +1,186 @@
+package com.jpsoft.printing.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.printing.modules.base.entity.Customer;
+import com.jpsoft.printing.modules.base.entity.Work;
+import com.jpsoft.printing.modules.base.service.CustomerService;
+import com.jpsoft.printing.modules.base.service.StockService;
+import com.jpsoft.printing.modules.base.service.WorkService;
+import com.jpsoft.printing.modules.common.utils.PojoUtils;
+import com.jpsoft.printing.modules.common.dto.Sort;
+import com.jpsoft.printing.modules.common.dto.MessageResult;
+import com.jpsoft.printing.modules.base.entity.Account;
+import com.jpsoft.printing.modules.base.service.AccountService;
+import com.jpsoft.printing.modules.sys.service.SysLogService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/account")
+@Api(description = "account")
+public class AccountController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+	@Autowired
+    private SysLogService sysLogService;
+    @Autowired
+    private CustomerService customerService;
+    @Autowired
+    private WorkService workService;
+    @Autowired
+    private StockService stockService;
+    @Autowired
+    private AccountService accountService;
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult edit(@PathVariable("id") String id){
+        MessageResult msgResult = new MessageResult<>();
+
+        try {
+            Account account = accountService.get(id);
+
+            if (account != null) {
+                msgResult.setResult(true);
+                msgResult.setData(account);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+	@ApiOperation(value="删除")
+    @PostMapping("delete/{id}")
+	@Transactional(rollbackFor = Exception.class)
+    public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject,HttpServletRequest request){
+		Long begin = System.currentTimeMillis();
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            Account account = accountService.get(id);
+            account.setDelFlag(true);
+            account.setUpdateBy(subject);
+            account.setUpdateTime(new Date());
+
+            int affectCount = accountService.update(account);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+				msgResult.setMessage("删除成功");
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+			
+			Long end = System.currentTimeMillis();
+            sysLogService.addLog(subject,request.getRemoteAddr(),request.getServletPath(),id,end-begin,null,msgResult.getMessage());
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String id,
+            @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 + "%");
+        }
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("id_","asc"));
+
+        Page<Account> page = accountService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="建立信息")
+    @GetMapping("createBill/{id}")
+    public MessageResult createBill(@PathVariable("id") String id){
+        MessageResult msgResult = new MessageResult<>();
+
+        try {
+            Work work = workService.get(id);
+
+            if (work != null) {
+                BigDecimal actualQuantity = stockService.getActualQuantity(id);
+                if(actualQuantity != null) {
+                    work.setActualQuantity(actualQuantity);
+
+                    BigDecimal rollQuantity = stockService.getRollQuantity(id);
+                    work.setRollQuantity(rollQuantity);
+                }
+                else{
+                    work.setActualQuantity(new BigDecimal(0));
+                    work.setRollQuantity(new BigDecimal(0));
+                }
+                work.setClothQuantity(work.getActualQuantity().subtract(work.getEstimateQuantity()));
+
+                Customer customer = customerService.get(work.getCustomerId());
+                if(customer != null){
+                    String allName = "";
+
+                    if(StringUtils.isNotEmpty(customer.getCompany())){
+                        allName = customer.getName() + "(" + customer.getCompany() + ")";
+                    }
+                    else{
+                        allName = customer.getName();
+                    }
+
+                    work.setCustomerName(allName);
+                }
+
+                work.setActualAmount(work.getActualQuantity().multiply(work.getUnitPrice()));
+                work.setClothAmount(work.getClothQuantity().multiply(work.getClothPrice()));
+                work.setRollAmount(work.getRollQuantity().multiply(work.getWages()));
+                work.setTotalAmount(work.getActualAmount().add(work.getClothAmount()).add(work.getRollAmount()));
+
+                msgResult.setResult(true);
+                msgResult.setData(work);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+}