Browse Source

为物料添加操作人员记录

lwx_dev
erdanergou 3 years ago
parent
commit
48b09084bf
  1. 16
      src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java
  2. 9
      src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml
  3. 8
      src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java
  4. 48
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  5. 1
      src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java
  6. 9
      target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

16
src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java

@ -257,7 +257,13 @@ public class MaterialController {
* @return
*/
@PostMapping("/material_add")
public RestResponse materialAdd(@RequestBody Map<String, Object> map) {
public RestResponse materialAdd(@RequestBody Map<String, Object> map,HttpServletRequest request) {
String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
map.put("uid",userToken.getId());
return CrudUtil.insertHandle(materialService.insertMaterial(map), 1);
}
@ -287,7 +293,13 @@ public class MaterialController {
* @return
*/
@PostMapping("/material_edit")
public RestResponse updateDepository(@RequestBody Map<String, Object> map) {
public RestResponse updateDepository(@RequestBody Map<String, Object> map,HttpServletRequest request) {
String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
map.put("uid",userToken.getId());
if (map.containsKey("state")) {
map.put("state", 1);
} else {

9
src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

@ -761,7 +761,7 @@
<insert id="insertMaterial" useGeneratedKeys="true" keyProperty="id">
INSERT INTO material (
id, depository_id, mname, quantity, price,
type_id,code,unit,version,texture,amounts,depositoryCode,producedDate,shelfLife,brand,productionPlace,remark
type_id,code,unit,version,texture,amounts,depositoryCode,producedDate,shelfLife,brand,productionPlace,remark,uid
) VALUES (
#{id},
<if test="depositoryId != null">
@ -804,7 +804,8 @@
#{shelfLife},
#{brand},
#{productionPlace},
#{remark}
#{remark},
#{uid}
)
</insert>
<!-- 插入数据 -->
@ -938,6 +939,9 @@
<if test="depositoryId != null">
depository_id = #{depositoryId},
</if>
<if test="uid != '' and uid != null">
uid = #{uid},
</if>
<if test="mname != null">
mname = #{mname},
</if>
@ -986,7 +990,6 @@
<if test="brand != '' and brand != null">
brand = #{brand},
</if>
<if test="remark != '' and remark != null">
remark = #{remark}
</if>

8
src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java

@ -445,13 +445,7 @@ public interface DepositoryRecordService {
*/
String createCode(String depositoryName, String key, String type, String mainDeparmentName);
/**
* 将刚入库的记录删除
*
* @param map
* @return
*/
Integer deleteApplicaionInPlace(Map<String, Object> map);
/**

48
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -872,54 +872,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
return placeMapper.UpdatePlace(placeById);
}
/**
* 将刚入库的记录删除
*
* @param map
* @return
*/
@Override
public Integer deleteApplicaionInPlace(Map<String, Object> map) {
String code = map.get("code").toString();
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity"));
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId"));
// 获取材料基本信息
Material materialById = materialMapper.findMaterialById(mid);
Object oldPrice1 = map.get("oldPrice");
Double oldPrice = 0.0;
if (oldPrice1 != null) {
oldPrice = Double.parseDouble(oldPrice1.toString());
}
Double price = Double.parseDouble(map.get("price").toString());
Integer id = ObjectFormatUtil.toInteger(map.get("id"));
String deleteType = map.get("delete").toString();
Map<String, Object> params = new HashMap<>();
params.put("code", materialById.getCode());
params.put("depositoryId", depositoryId);
List<Material> materialByCondition = materialMapper.findMaterialByCondition(params);
if (materialByCondition.size() < 1) {
throw new MyException("出现未知错误,联系开发人员");
}
if ("in".equals(deleteType)) {
// 删除入库记录
depositoryRecordMapper.deleteApplicationInRecordById(id);
// 将库存还原
Material material = materialByCondition.get(0);
Map<String, Object> update = new HashMap<>();
update.put("quantity", material.getQuantity() - quantity * 100);
update.put("price", oldPrice);
update.put("amounts", material.getAmounts() - quantity * price);
update.put("id", material.getId());
return materialMapper.updateMaterial(update);
} else if ("out".equals(deleteType)) {
return null;
} else {
throw new MyException("请求参数错误");
}
}
/**
* 插入一条出库子订单

1
src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

@ -759,6 +759,7 @@ public class ExcelServiceImpl implements ExcelService {
param.put("id", excelVo.getId());
param.put("brand", excelVo.getBrand());
param.put("price", excelVo.getPrice() == null ? "0" : excelVo.getPrice());
param.put("uid",userByPort.getId());
materialService.insertMaterial(param);
success.add(excelVo);
if ((i + 1) % 100 == 0 || excelVosForMaterial.size() - 1 == i) {

9
target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml

@ -761,7 +761,7 @@
<insert id="insertMaterial" useGeneratedKeys="true" keyProperty="id">
INSERT INTO material (
id, depository_id, mname, quantity, price,
type_id,code,unit,version,texture,amounts,depositoryCode,producedDate,shelfLife,brand,productionPlace,remark
type_id,code,unit,version,texture,amounts,depositoryCode,producedDate,shelfLife,brand,productionPlace,remark,uid
) VALUES (
#{id},
<if test="depositoryId != null">
@ -804,7 +804,8 @@
#{shelfLife},
#{brand},
#{productionPlace},
#{remark}
#{remark},
#{uid}
)
</insert>
<!-- 插入数据 -->
@ -938,6 +939,9 @@
<if test="depositoryId != null">
depository_id = #{depositoryId},
</if>
<if test="uid != '' and uid != null">
uid = #{uid},
</if>
<if test="mname != null">
mname = #{mname},
</if>
@ -986,7 +990,6 @@
<if test="brand != '' and brand != null">
brand = #{brand},
</if>
<if test="remark != '' and remark != null">
remark = #{remark}
</if>

Loading…
Cancel
Save