jz.kai 1 år sedan
förälder
incheckning
b9880fcbb4

+ 18 - 0
common/src/main/java/com/jpsoft/printing/modules/base/dao/WorkDAO.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.Work;
+import java.util.Map;
+import com.jpsoft.printing.modules.common.dto.Sort;
+
+@Repository
+public interface WorkDAO {
+	int insert(Work entity);
+	int update(Work entity);
+	int exist(String id);
+	Work get(String id);
+	int delete(String id);
+	List<Work> list();
+	List<Work> search(Map<String,Object> searchParams,List<Sort> sortList);
+}

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

@@ -38,4 +38,6 @@ public class Customer {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
 	    @ApiModelProperty(value = "更新时间")
     private Date updateTime;
+
+    private String allName;
 }

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

@@ -0,0 +1,66 @@
+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_work的实体类
+ */
+@Data
+@ApiModel(value = "base_work的实体类")
+public class Work {
+        @ApiModelProperty(value = "ID")
+    private String id;
+        @ApiModelProperty(value = "客户编号")
+    private String customerId;
+    private String customerName;
+        @ApiModelProperty(value = "品种及规格")
+    private String name;
+        @ApiModelProperty(value = "幅宽")
+    private Integer width;
+        @ApiModelProperty(value = "编号")
+    private String number;
+        @DateTimeFormat(pattern="yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
+	    @ApiModelProperty(value = "投坯日")
+    private Date processDate;
+        @ApiModelProperty(value = "投坯数")
+    private String processVolume;
+        @ApiModelProperty(value = "伸长率")
+    private BigDecimal ratio;
+        @ApiModelProperty(value = "色泽")
+    private String colour;
+        @ApiModelProperty(value = "应交成品数")
+    private BigDecimal estimateQuantity;
+        @ApiModelProperty(value = "单价")
+    private BigDecimal unitPrice;
+        @ApiModelProperty(value = "原因")
+    private String reason;
+        @ApiModelProperty(value = "坯布价")
+    private BigDecimal clothPrice;
+        @ApiModelProperty(value = "力资")
+    private BigDecimal wages;
+        @ApiModelProperty(value = "备注")
+    private String remark;
+        @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;
+}

+ 17 - 0
common/src/main/java/com/jpsoft/printing/modules/base/service/WorkService.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.Work;
+import com.github.pagehelper.Page;
+import com.jpsoft.printing.modules.common.dto.Sort;
+
+public interface WorkService {
+	Work get(String id);
+	boolean exist(String id);
+	int insert(Work model);
+	int update(Work model);
+	int delete(String id);
+	List<Work> list();
+	Page<Work> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+}

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

+ 1 - 1
common/src/main/resources/mapper/base/Customer.xml

@@ -78,7 +78,7 @@ id_,company_,name_,phone_,del_flag,create_by,create_time,update_by,update_time
 		select count(*) from base_customer where id_=#{0}
 	</select>
 	<select id="list" resultMap="CustomerMap">
-		select * from base_customer
+		select * from base_customer where del_flag = 0
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="CustomerMap">
 		<![CDATA[

+ 158 - 0
common/src/main/resources/mapper/base/Work.xml

@@ -0,0 +1,158 @@
+<?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.WorkDAO">
+	<resultMap id="WorkMap" type="com.jpsoft.printing.modules.base.entity.Work">
+		<id property="id" column="id_" />
+		<result property="customerId" column="customer_id" />
+		<result property="name" column="name_" />
+		<result property="width" column="width_" />
+		<result property="number" column="number_" />
+		<result property="processDate" column="process_date" />
+		<result property="processVolume" column="process_volume" />
+		<result property="ratio" column="ratio_" />
+		<result property="colour" column="colour_" />
+		<result property="estimateQuantity" column="estimate_quantity" />
+		<result property="unitPrice" column="unit_price" />
+		<result property="reason" column="reason_" />
+		<result property="clothPrice" column="cloth_price" />
+		<result property="wages" column="wages_" />
+		<result property="remark" column="remark_" />
+		<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.Work">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_work
+	    (id_,customer_id,name_,width_,number_,process_date,process_volume,ratio_,colour_,estimate_quantity,unit_price,reason_,cloth_price,wages_,remark_,del_flag,create_by,create_time,update_by,update_time)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{customerId,jdbcType=VARCHAR}
+,#{name,jdbcType=VARCHAR}
+,#{width,jdbcType= NUMERIC }
+,#{number,jdbcType=VARCHAR}
+,#{processDate,jdbcType= TIMESTAMP }
+,#{processVolume,jdbcType=VARCHAR}
+,#{ratio,jdbcType= NUMERIC }
+,#{colour,jdbcType=VARCHAR}
+,#{estimateQuantity,jdbcType= NUMERIC }
+,#{unitPrice,jdbcType= NUMERIC }
+,#{reason,jdbcType=VARCHAR}
+,#{clothPrice,jdbcType= NUMERIC }
+,#{wages,jdbcType= NUMERIC }
+,#{remark,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_work where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.printing.modules.base.entity.Work">
+		update base_work
+		<set>
+				<if test="customerId!=null">
+		customer_id=#{customerId,jdbcType=VARCHAR},
+		</if>
+				<if test="name!=null">
+		name_=#{name,jdbcType=VARCHAR},
+		</if>
+				<if test="width!=null">
+		width_=#{width,jdbcType= NUMERIC },
+		</if>
+				<if test="number!=null">
+		number_=#{number,jdbcType=VARCHAR},
+		</if>
+				<if test="processDate!=null">
+		process_date=#{processDate,jdbcType= TIMESTAMP },
+		</if>
+				<if test="processVolume!=null">
+		process_volume=#{processVolume,jdbcType=VARCHAR},
+		</if>
+				<if test="ratio!=null">
+		ratio_=#{ratio,jdbcType= NUMERIC },
+		</if>
+				<if test="colour!=null">
+		colour_=#{colour,jdbcType=VARCHAR},
+		</if>
+				<if test="estimateQuantity!=null">
+		estimate_quantity=#{estimateQuantity,jdbcType= NUMERIC },
+		</if>
+				<if test="unitPrice!=null">
+		unit_price=#{unitPrice,jdbcType= NUMERIC },
+		</if>
+				<if test="reason!=null">
+		reason_=#{reason,jdbcType=VARCHAR},
+		</if>
+				<if test="clothPrice!=null">
+		cloth_price=#{clothPrice,jdbcType= NUMERIC },
+		</if>
+				<if test="wages!=null">
+		wages_=#{wages,jdbcType= NUMERIC },
+		</if>
+				<if test="remark!=null">
+		remark_=#{remark,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="WorkMap">
+		select
+id_,customer_id,name_,width_,number_,process_date,process_volume,ratio_,colour_,estimate_quantity,unit_price,reason_,cloth_price,wages_,remark_,del_flag,create_by,create_time,update_by,update_time		from base_work where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_work where id_=#{0}
+	</select>
+	<select id="list" resultMap="WorkMap">
+		select * from base_work
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="WorkMap">
+		<![CDATA[
+			select * from base_work
+		]]>
+		<where>
+			del_flag = 0
+			<if test="searchParams.customerId != null">
+				and customer_id = #{searchParams.customerId}
+			</if>
+			<if test="searchParams.name != null">
+				and name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.number != null">
+				and number_ like #{searchParams.number}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+</mapper>

+ 25 - 0
web/src/main/java/com/jpsoft/printing/modules/base/controller/CustomerController.java

@@ -250,4 +250,29 @@ public class CustomerController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="select列表")
+    @RequestMapping(value = "findList",method = RequestMethod.POST)
+    public MessageResult findList(@RequestAttribute String subject){
+        MessageResult msgResult = new MessageResult<>();
+
+        List<Customer> list = customerService.list();
+        for(Customer customer : list){
+            String allName = "";
+
+            if(StringUtils.isNotEmpty(customer.getCompany())){
+                allName = customer.getName() + "(" + customer.getCompany() + ")";
+            }
+            else{
+                allName = customer.getName();
+            }
+
+            customer.setAllName(allName);
+        }
+
+        msgResult.setResult(true);
+        msgResult.setData(list);
+
+        return msgResult;
+    }
 }

+ 270 - 0
web/src/main/java/com/jpsoft/printing/modules/base/controller/WorkController.java

@@ -0,0 +1,270 @@
+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.service.CustomerService;
+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.Work;
+import com.jpsoft.printing.modules.base.service.WorkService;
+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.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/work")
+@Api(description = "work")
+public class WorkController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+	@Autowired
+    private SysLogService sysLogService;
+    @Autowired
+    private CustomerService customerService;
+    @Autowired
+    private WorkService workService;
+
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<Work> create(){
+        MessageResult<Work> msgResult = new MessageResult<>();
+
+        Work work = new Work();
+
+        msgResult.setData(work);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+    
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+	@Transactional(rollbackFor = Exception.class)
+    public MessageResult<Work> add(@RequestBody Work work,@RequestAttribute String subject,HttpServletRequest request){
+		Long begin = System.currentTimeMillis();
+        MessageResult<Work> msgResult = new MessageResult<>();
+
+        try {
+            work.setId(UUID.randomUUID().toString());
+            work.setDelFlag(false);
+            work.setCreateBy(subject);
+            work.setCreateTime(new Date());
+            
+            int affectCount = workService.insert(work);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(work);
+				msgResult.setMessage("数据库添加成功");
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+			
+			Long end = System.currentTimeMillis();
+            sysLogService.addLog(subject,request.getRemoteAddr(),request.getServletPath(),work.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<Work> edit(@PathVariable("id") String id){
+        MessageResult<Work> msgResult = new MessageResult<>();
+
+        try {
+            Work work = workService.get(id);
+
+            if (work != null) {
+                msgResult.setResult(true);
+                msgResult.setData(work);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+	@Transactional(rollbackFor = Exception.class)
+    public MessageResult<Work> update(@RequestBody Work work,@RequestAttribute String subject,HttpServletRequest request){
+		Long begin = System.currentTimeMillis();
+        MessageResult<Work> msgResult = new MessageResult<>();
+
+        try {
+            work.setUpdateBy(subject);
+            work.setUpdateTime(new Date());
+            
+            int affectCount = workService.update(work);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(work);
+				msgResult.setMessage("数据库更新成功");
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+			
+			Long end = System.currentTimeMillis();
+            sysLogService.addLog(subject,request.getRemoteAddr(),request.getServletPath(),work.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="删除")
+    @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 {
+            Work work = workService.get(id);
+            work.setDelFlag(true);
+            work.setUpdateBy(subject);
+            work.setUpdateTime(new Date());
+
+            int affectCount = workService.update(work);
+
+            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="批量删除")
+    @PostMapping("batchDelete")
+	@Transactional(rollbackFor = Exception.class)
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject,HttpServletRequest request){
+		Long begin = System.currentTimeMillis();
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (String id : idList) {
+                Work work = workService.get(id);
+                work.setDelFlag(true);
+                work.setUpdateBy(subject);
+                work.setUpdateTime(new Date());
+
+                affectCount += workService.update(work);
+            }
+
+            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(),String.join(",",idList),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 customerId, String name, String number,
+            @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(customerId)) {
+            searchParams.put("customerId",customerId);
+        }
+        if (StringUtils.isNotEmpty(name)) {
+            searchParams.put("name","%" + name + "%");
+        }
+        if (StringUtils.isNotEmpty(number)) {
+            searchParams.put("number","%" + number + "%");
+        }
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("id_","asc"));
+
+        Page<Work> page = workService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+        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);
+        }
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+}