Commit 7ce04f96 by zhangtw

申领查询、添加、历史记录

parent 6e3a4c62
...@@ -5,9 +5,15 @@ import com.scpyun.base.core.annotation.Api; ...@@ -5,9 +5,15 @@ import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation; import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException; import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService; import com.scpyun.base.db.service.CommonService;
import com.scpyun.base.utils.UUID;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -20,10 +26,11 @@ public class KeyDmBorrowServiceImpl { ...@@ -20,10 +26,11 @@ public class KeyDmBorrowServiceImpl {
private static final String SUCCESS = "success"; private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow."; private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow.";
private final String detailNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrowDetail.";
private final String materialNamespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog.";
@ApiOperation(value = "领用申请列表", desc = "分页查询") @ApiOperation(value = "领用申请列表", desc = "分页查询")
public Page<Map<String, Object>> selectList(Map<String, Object> map) { public Page<Map<String, Object>> selectList(Page<Map<String, Object>> map) {
if (map == null) map = new HashMap<>(); if (map == null) map = new Page<>();
return commonService.findPage(namespace + "selectList", map); return commonService.findPage(namespace + "selectList", map);
} }
...@@ -33,25 +40,60 @@ public class KeyDmBorrowServiceImpl { ...@@ -33,25 +40,60 @@ public class KeyDmBorrowServiceImpl {
return commonService.findPage(namespace + "selectPendingList", map); return commonService.findPage(namespace + "selectPendingList", map);
} }
@ApiOperation(value = "历史申请列表", desc = "分页查询历史申请")
public Page<Map<String, Object>> selectHistoryList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectHistoryList", map);
}
@ApiOperation(value = "保存申请(含明细)", desc = "新增或修改申请") @ApiOperation(value = "保存申请(含明细)", desc = "新增或修改申请")
public String save(Map<String, Object> map) { public String save(Map<String, Object> map) {
if (map == null) throw new CustomException("参数不能为空"); if (map == null) throw new CustomException("参数不能为空");
System.out.println(map);
Object id = map.get("id"); Object id = map.get("id");
List<Map<String, Object>> details = (List<Map<String, Object>>) map.get("details"); List<Map<String, Object>> details = (List<Map<String, Object>>) map.get("details");
Map<String, Object> user = (Map<String, Object>) map.get("_user");
if (id == null || String.valueOf(id).trim().isEmpty()) { if (id == null || String.valueOf(id).trim().isEmpty()) {
map.put("id",UUID.randomUUID().toString());
map.put("application_no","borrow");
map.put("applicant_id",user.get("id"));
map.put("applicant_name", user.get("name"));
map.put("department_id", user.get("company_id"));
map.put("department_name", user.get("company_name"));
//日期格式转换
Instant instant = Instant.parse((String) map.get("expected_return_date"));
LocalDate localDate = instant.atZone(ZoneId.systemDefault()).toLocalDate();
Date expected_return_date = java.sql.Date.valueOf(localDate);
map.put("expected_return_date",expected_return_date);
map.put("approval_status", 0);
map.put("issue_status", 0);
map.put("is_used", 1);
map.put("create_by", user.get("id"));
map.put("create_time", new Date());
map.put("order_no", 0);
System.out.println(map);
// insert application // insert application
if (commonService.insert(namespace + "insert", map) != 1) throw new CustomException("保存失败"); if (commonService.insert(namespace + "insert", map) != 1) throw new CustomException("保存失败");
// insert details if any // insert details if any
if (details != null) { if (details != null) {
for (Map<String, Object> d : details) { for (Map<String, Object> d : details) {
d.put("id",UUID.randomUUID().toString());
d.put("application_id", map.get("id")); d.put("application_id", map.get("id"));
commonService.insert(namespace + "insertDetail", d); d.put("material_id", "测试");
d.put("is_used", 1);
d.put("create_by", user.get("id"));
d.put("create_time", new Date());
d.put("order_no", 0);
commonService.insert( detailNamespace + "insertDetail", d);
} }
} }
} else { } else {
int aff = commonService.update(namespace + "update", map); int aff = commonService.update(namespace + "update", map);
if (aff < 0) throw new CustomException("保存失败"); if (aff < 0) throw new CustomException("保存失败");
// for simplicity, delete old details and insert new // for simplicity, delete old details and insert new
System.out.println("---------------------------------------------");
System.out.println(id);
commonService.delete(namespace + "deleteDetailsByApplicationId", map); commonService.delete(namespace + "deleteDetailsByApplicationId", map);
if (details != null) { if (details != null) {
for (Map<String, Object> d : details) { for (Map<String, Object> d : details) {
...@@ -108,11 +150,13 @@ public class KeyDmBorrowServiceImpl { ...@@ -108,11 +150,13 @@ public class KeyDmBorrowServiceImpl {
Map<String, Object> ret = new HashMap<>(); Map<String, Object> ret = new HashMap<>();
Map<String, Object> app = commonService.getObject(namespace + "getById", map); Map<String, Object> app = commonService.getObject(namespace + "getById", map);
ret.putAll(app == null ? new HashMap<>() : app); ret.putAll(app == null ? new HashMap<>() : app);
List<Map<String, Object>> details = commonService.findList(namespace + "selectDetailsByApplicationId", map); List<Map<String, Object>> details = commonService.findList(detailNamespace + "selectDetailsByApplicationId", map);
ret.put("details", details == null ? new java.util.ArrayList<>() : details); ret.put("details", details == null ? new java.util.ArrayList<>() : details);
System.out.println(ret);
// logs from material log by application relation // logs from material log by application relation
List<Map<String, Object>> logs = commonService.findList(namespace + "selectLogsByApplicationId", map); List<Map<String, Object>> logs = commonService.findList(materialNamespace + "selectLogsByApplicationId", map);
ret.put("logs", logs == null ? new java.util.ArrayList<>() : logs); ret.put("logs", logs == null ? new java.util.ArrayList<>() : logs);
System.out.println(ret);
return ret; return ret;
} }
} }
......
...@@ -2,12 +2,18 @@ ...@@ -2,12 +2,18 @@
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow" name="领用申请"> <mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow" name="领用申请">
<select id="selectList" parameterType="page" resultType="map"> <select id="selectList" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_borrow_application SELECT * FROM jl_key_dm_borrow_application
<where> <where>
AND is_used = 1 is_used = 1
<if test="params.applicant_name != null and params.applicant_name != ''"> <if test="params.params.applicant_name != null and params.params.applicant_name != ''">
AND (applicant_name LIKE CONCAT('%', #{params.applicant_name}, '%') OR application_no LIKE CONCAT('%', #{params.applicant_name}, '%')) AND applicant_name LIKE CONCAT('%', #{params.params.applicant_name}, '%')
</if>
<if test="params.params.application_no != null and params.params.application_no != ''">
AND application_no LIKE CONCAT('%', #{params.params.application_no}, '%')
</if>
<if test="params.params.approval_status != null and params.params.approval_status != ''">
AND approval_status = #{params.params.approval_status}
</if> </if>
</where> </where>
ORDER BY create_time DESC ORDER BY create_time DESC
...@@ -16,12 +22,29 @@ ...@@ -16,12 +22,29 @@
<select id="selectPendingList" parameterType="page" resultType="map"> <select id="selectPendingList" parameterType="page" resultType="map">
SELECT * FROM jl_key_dm_borrow_application SELECT * FROM jl_key_dm_borrow_application
<where> <where>
AND is_used = 1 is_used = 1
AND approval_status = 1 AND approval_status = 1
</where> </where>
ORDER BY submit_time DESC ORDER BY submit_time DESC
</select> </select>
<select id="selectHistoryList" parameterType="page" resultType="map">
SELECT * FROM jl_key_dm_borrow_application
<where>
is_used = 1
<if test="params.applicant_name != null and params.applicant_name != ''">
AND applicant_name LIKE CONCAT('%', #{params.applicant_name}, '%')
</if>
<if test="params.application_no != null and params.application_no != ''">
AND application_no LIKE CONCAT('%', #{params.application_no}, '%')
</if>
<if test="params.approval_status != null and params.approval_status != ''">
AND approval_status = #{params.approval_status}
</if>
</where>
ORDER BY approval_complete_time DESC
</select>
<select id="getById" parameterType="map" resultType="map"> <select id="getById" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_borrow_application WHERE id = #{id} LIMIT 1 SELECT * FROM jl_key_dm_borrow_application WHERE id = #{id} LIMIT 1
</select> </select>
...@@ -81,7 +104,9 @@ ...@@ -81,7 +104,9 @@
<insert id="insertMaterialLogByApplication" parameterType="map"> <insert id="insertMaterialLogByApplication" parameterType="map">
<!-- 简化:实现者可在业务层调用单条插入,此处为占位 --> <!-- 简化:实现者可在业务层调用单条插入,此处为占位 -->
</insert> </insert>
<select id="selectLogsByApplicationId" parameterType="map">
</select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论