Browse Source

实现按拆单单位入库功能

lwx_dev
erdanergou 3 years ago
parent
commit
a6d77f584a
  1. 769
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 18
      src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java
  3. 10
      src/main/java/com/dreamchaser/depository_manage/controller/PageController.java
  4. 2
      src/main/java/com/dreamchaser/depository_manage/controller/PlaceController.java
  5. 28
      src/main/java/com/dreamchaser/depository_manage/controller/SplitController.java
  6. 5
      src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecordMin.java
  7. 1
      src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfoByInventory.java
  8. 5
      src/main/java/com/dreamchaser/depository_manage/entity/Material.java
  9. 4
      src/main/java/com/dreamchaser/depository_manage/entity/MaterialAndBarCode.java
  10. 19
      src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml
  11. 10
      src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java
  12. 10
      src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml
  13. 2
      src/main/java/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.java
  14. 2
      src/main/java/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.xml
  15. 6
      src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java
  16. 13
      src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java
  17. 8
      src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java
  18. 185
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  19. 51
      src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java
  20. 42
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  21. 22
      src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java
  22. 110
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java
  23. 6
      src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java
  24. 85
      src/main/resources/templates/pages/application/application-in.html
  25. 2
      src/main/resources/templates/pages/application/form-step-look.html
  26. 2
      src/main/resources/templates/pages/depository/table-in.html
  27. 6
      src/main/resources/templates/pages/depository/table-stock.html
  28. 3
      src/test/java/com/dreamchaser/depository_manage/TestForOther.java
  29. 19
      target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml
  30. 10
      target/classes/com/dreamchaser/depository_manage/mapper/MaterialMapper.xml
  31. 2
      target/classes/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.xml
  32. 85
      target/classes/templates/pages/application/application-in.html
  33. 2
      target/classes/templates/pages/application/form-step-look.html
  34. 2
      target/classes/templates/pages/depository/table-in.html
  35. 6
      target/classes/templates/pages/depository/table-stock.html

769
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

File diff suppressed because it is too large

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

@ -296,12 +296,17 @@ public class MaterialController {
if (inventory.size() > 0) {
InventoryP materialP = inventory.get(0);
materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition);
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(materialP.getMid());
materialP.setSplitInfoList(splitInfoByMid);
map.put("materialById", materialP);
} else {
materialById.setPrice(0.0);
materialById.setMaterialAndBarCodeList(materialByBarCodeByCondition);
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(materialById.getId());
materialById.setSplitInfoList(splitInfoByMid);
map.put("materialById", materialById);
}
map.put("placeList", placePList);
return new RestResponse(map, 1, 200);
}
@ -669,11 +674,15 @@ public class MaterialController {
ip.setPlacePList(placePList);
// 设置物料与条形码的对应关系
ip.setMaterialAndBarCodeList(materialByBarCodeByCondition);
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(ip.getMid());
ip.setSplitInfoList(splitInfoByMid);
return new RestResponse(ip);
} else {
MaterialP mp = new MaterialP(material);
// 设置物料与条形码的对应关系
mp.setMaterialAndBarCodeList(materialByBarCodeByCondition);
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(mp.getMid());
mp.setSplitInfoList(splitInfoByMid);
return new RestResponse(mp);
}
@ -786,7 +795,7 @@ public class MaterialController {
Boolean flag = true;
JSONObject material = (JSONObject) materialListByJson.get(i);
param.put("mcode", material.getString("code"));
InventoryP mp = new InventoryP(materialService.findInventoryByMid(material.getInteger("mid")));
InventoryP mp = new InventoryP(materialService.findInventoryById(material.getInteger("mid")));
// 获取物料与条形码的对应关系
List<MaterialAndBarCode> materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(param);
param.put("mcode", material.getString("code"));
@ -967,7 +976,8 @@ public class MaterialController {
materialByBarCode = materialService.findMaterialByBarCode(qrCode);
}
List<SplitInfo> splitInfoByMid = splitUnitService.findSplitInfoByMid(materialByBarCode.getMid());
materialByBarCode.setSplitInfoList(splitInfoByMid);
result.put("material", materialByBarCode);
return new RestResponse(result);
}
@ -1173,7 +1183,7 @@ public class MaterialController {
Boolean tempflag = true;
JSONObject material = (JSONObject) materialListByJson.get(i);
param.put("mcode", material.getString("code"));
InventoryP mp = new InventoryP(materialService.findInventoryByMid(material.getInteger("mid")));
InventoryP mp = new InventoryP(materialService.findInventoryById(material.getInteger("mid")));
// 获取物料与条形码的对应关系
List<MaterialAndBarCode> materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(param);
param.put("mcode", material.getString("code"));
@ -1525,7 +1535,7 @@ public class MaterialController {
List<String> mcodeList = new ArrayList<>();
for (int i = 0; i < placeAndMaterialByPid.size(); i++) {
MaterialAndPlace materialAndPlace = placeAndMaterialByPid.get(i);
Inventory materialById = materialService.findInventoryByMid(materialAndPlace.getMid());
Inventory materialById = materialService.findInventoryById(materialAndPlace.getMid());
mcodeList.add(materialById.getCode());
}
pp.setMcodeList(mcodeList);

10
src/main/java/com/dreamchaser/depository_manage/controller/PageController.java

@ -666,7 +666,7 @@ public class PageController {
Inventory materialById = new Inventory();
Depository depositoryRecordById = new Depository();
if (mid != null) {
materialById = materialService.findInventoryByMid(mid);
materialById = materialService.findInventoryById(mid);
}
if (depositoryId != null) {
depositoryRecordById = depositoryService.findDepositoryById(depositoryId);
@ -1228,7 +1228,7 @@ public class PageController {
// 获取子订单信息
ApplicationOutRecordMin applicationOutRecordMin = applicationOutRecordMinByParent.get(i);
// 获取出库物料信息
Inventory materialById = materialService.findInventoryByMid(applicationOutRecordMin.getMid());
Inventory materialById = materialService.findInventoryById(applicationOutRecordMin.getMid());
// 获取出库物料仓库信息
Depository depository = depositoryService.findDepositoryById(applicationOutRecordMin.getDepositoryId());
// 获取出库库位
@ -1314,7 +1314,7 @@ public class PageController {
ApplicationOutRecordMin recordMin = depositoryRecordService.findApplicationOutMinById(id);
ApplicationOutRecordMinP recordMinP = new ApplicationOutRecordMinP(recordMin);
// 获取出库物料信息
Inventory materialById = materialService.findInventoryByMid(recordMin.getMid());
Inventory materialById = materialService.findInventoryById(recordMin.getMid());
// 获取出库物料仓库信息
Depository depository = depositoryService.findDepositoryById(recordMin.getDepositoryId());
// 获取出库库位
@ -1375,7 +1375,7 @@ public class PageController {
ApplicationOutRecordMinP recordMinP = new ApplicationOutRecordMinP(applicationOutRecordMin);
// 获取出库物料信息
Inventory materialById = materialService.findInventoryByMid(applicationOutRecordMin.getMid());
Inventory materialById = materialService.findInventoryById(applicationOutRecordMin.getMid());
// 获取出库物料仓库信息
Depository depository = depositoryService.findDepositoryById(applicationOutRecordMin.getDepositoryId());
// 获取出库库位
@ -1899,7 +1899,7 @@ public class PageController {
// 获取当前要处理的子订单
ApplicationOutRecordMin applicationOutMinById = depositoryRecordService.findApplicationOutMinById(id);
mv.setViewName("pages/scanQrCode/ScanBarOrQrCodeOut");
Inventory materialById = materialService.findInventoryByMid(applicationOutMinById.getMid());
Inventory materialById = materialService.findInventoryById(applicationOutMinById.getMid());
mv.addObject("materialById", materialById);
mv.addObject("record", applicationOutMinById);
return mv;

2
src/main/java/com/dreamchaser/depository_manage/controller/PlaceController.java

@ -55,7 +55,7 @@ public class PlaceController {
StringBuilder mname = new StringBuilder();
for (int j = 0; j < placeAndMaterialByPid.size(); j++) {
Integer mid = placeAndMaterialByPid.get(j).getMid();
Inventory materialById = materialService.findInventoryByMid(mid);
Inventory materialById = materialService.findInventoryById(mid);
mname.append(materialById.getMname()+",");
}
placeP.setMname(mname.toString());

28
src/main/java/com/dreamchaser/depository_manage/controller/SplitController.java

@ -1,10 +1,12 @@
package com.dreamchaser.depository_manage.controller;
import com.dreamchaser.depository_manage.entity.Inventory;
import com.dreamchaser.depository_manage.entity.SplitInfo;
import com.dreamchaser.depository_manage.exception.MyException;
import com.dreamchaser.depository_manage.pojo.RestResponse;
import com.dreamchaser.depository_manage.pojo.StatusInfo;
import com.dreamchaser.depository_manage.service.MaterialService;
import com.dreamchaser.depository_manage.service.SplitUnitService;
import com.dreamchaser.depository_manage.utils.CrudUtil;
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil;
@ -23,6 +25,9 @@ public class SplitController {
@Autowired
SplitUnitService splitUnitService;
@Autowired
MaterialService materialService;
/**
* 用于添加一条拆单记录
@ -107,4 +112,27 @@ public class SplitController {
throw new MyException("缺少必要参数");
}
}
@PostMapping("/calcPriceForSplit")
public RestResponse calcPriceForSplit(@RequestBody Map<String,Object> map){
// 通过物料id与计量单位获取对应拆单信息
SplitInfo splitInfoByMidAndUnit = splitUnitService.findSplitInfoByMidAndUnit(map);
if(splitInfoByMidAndUnit != null){
// 如果有拆单信息,获取对应物料的库存记录
List<Inventory> inventoryByMid = materialService.findInventoryByMid(splitInfoByMidAndUnit.getMid());
if(inventoryByMid.size() > 0){
Inventory inventory = inventoryByMid.get(0);
return new RestResponse(inventory.getPrice() / splitInfoByMidAndUnit.getQuantity());
}
}else{
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
List<Inventory> inventoryList = materialService.findInventoryByMid(mid);
if(inventoryList.size() > 0){
Inventory inventory = inventoryList.get(0);
return new RestResponse(inventory.getPrice());
}
}
return new RestResponse(0);
}
}

5
src/main/java/com/dreamchaser/depository_manage/entity/ApplicationOutRecordMin.java

@ -59,4 +59,9 @@ public class ApplicationOutRecordMin {
*/
private Integer trueOut;
/**
* 出库物料的单位
*/
private String unit;
}

1
src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfoByInventory.java

@ -45,7 +45,6 @@ public class ExcelInfoByInventory {
/** 单价 */
@ExcelProperty("单价")
@ExcelValid(message = "单价未填写")
private String price;
/** 仓库编码 */

5
src/main/java/com/dreamchaser/depository_manage/entity/Material.java

@ -150,4 +150,9 @@ public class Material {
*/
private String showShelfLife;
/**
* 该物料对应的拆单记录
*/
private List<SplitInfo> splitInfoList;
}

4
src/main/java/com/dreamchaser/depository_manage/entity/MaterialAndBarCode.java

@ -75,7 +75,9 @@ public class MaterialAndBarCode {
*/
private Integer shelfLife;
/**
* 生产日期
* 该物料对应的拆单记录
*/
private List<SplitInfo> splitInfoList;
}

19
src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -62,6 +62,8 @@
<result column="mtexture" property="mtexture" jdbcType="VARCHAR" />
<result column="mkingdeecode" property="mkingdeecode" jdbcType="VARCHAR" />
<result column="mdepositoryCode" property="mdepositoryCode" jdbcType="VARCHAR" />
<result column="airUnit" property="airUnit" jdbcType="VARCHAR" />
</resultMap>
<!-- 插入出库记录-->
@ -105,6 +107,7 @@
<result column="parentId" property="parentId" jdbcType="INTEGER" />
<result column="code" property="code" jdbcType="VARCHAR" />
<result column="transferId" property="transferId" jdbcType="INTEGER" />
<result column="unit" property="unit" jdbcType="VARCHAR" />
</resultMap>
<!-- 表查询字段 -->
@ -129,11 +132,11 @@
</sql>
<sql id="allColumnsByApplicationInRecord">
id,mid,quantity,price,applicant_id,applicant_time,code,depository_id,applyRemark
id,mid,quantity,price,applicant_id,applicant_time,code,depository_id,applyRemark,airUnit
</sql>
<sql id="ApplicationInRecordInfo">
airid,mname,quantity,price,tname,applicant_time,aircode,dname,applicant_id,applyRemark,mcode,mversion,munit,mtexture,mkingdeecode,mdepositoryCode
airid,mname,quantity,price,tname,applicant_time,aircode,dname,applicant_id,applyRemark,mcode,mversion,munit,mtexture,mkingdeecode,mdepositoryCode,airUnit
</sql>
<sql id="ApplicationOutRecordInfo">
@ -142,7 +145,7 @@
</sql>
<sql id="ApplicationOutRecordMinInfo">
aorm.id,aorm.mid,aorm.depositoryId,aorm.placeId,aorm.quantity,aorm.code,aorm.checkId,aorm.parentId,aorm.transferId,aorm.trueOut
aorm.id,aorm.mid,aorm.depositoryId,aorm.placeId,aorm.quantity,aorm.code,aorm.checkId,aorm.parentId,aorm.transferId,aorm.trueOut,aorm.unit
</sql>
<!-- 查询所有数据行数 -->
<select id="findCount" resultType="integer">
@ -622,7 +625,7 @@
<!-- 插入一条入库记录-->
<insert id="insertApplicationInRecord" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into application_in_record (id,mid,quantity,price,applicant_id,applicant_time,depository_id,code,applyRemark)
insert into application_in_record (id,mid,quantity,price,applicant_id,applicant_time,depository_id,code,applyRemark,unit)
values(
#{id},
#{mid},
@ -632,7 +635,8 @@
#{applicant_time},
#{depositoryId},
#{code},
#{applyRemark}
#{applyRemark},
#{unit}
)
</insert>
@ -687,7 +691,7 @@
<!-- 插入一条出库子订单-->
<insert id="insertApplicationOutRecordMin" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into application_out_record_min (id,mid,quantity,code,depositoryId,placeId,checkId,parentId,transferId,trueOut)
insert into application_out_record_min (id,mid,quantity,code,depositoryId,placeId,checkId,parentId,transferId,trueOut,unit)
values(
#{id},
#{mid},
@ -698,7 +702,8 @@
#{checkId},
#{parentId},
#{transferId},
#{trueOut}
#{trueOut},
#{unit}
)
</insert>

10
src/main/java/com/dreamchaser/depository_manage/mapper/MaterialMapper.java

@ -166,12 +166,18 @@ public interface MaterialMapper {
Material findMaterialById(int id);
/**
* 根据物料id查询库存信息
* 根据库存id查询库存信息
* @param mid 库存id
* @return 库存信息
*/
Inventory findInventoryByMid(int mid);
Inventory findInventoryById(int mid);
/**
* 根据物料id获取对应库存信息
* @param mid 待查询物料id
* @return
*/
List<Inventory> findInventoryByMid(int mid);
/**

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

@ -229,7 +229,7 @@
AND mname LIKE CONCAT('%', #{mname}, '%')
</if>
<if test="version != null">
and version = #{version}
and version LIKE concat('%',#{version},'%')
</if>
<if test="quantity != null">
AND quantity = #{quantity}
@ -612,12 +612,18 @@
FROM material m WHERE m.id =#{id}
</select>
<select id="findInventoryByMid" resultMap="InventoryMap" parameterType="integer">
<select id="findInventoryById" resultMap="InventoryMap" parameterType="integer">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
FROM findInventory WHERE id =#{mid}
</select>
<select id="findInventoryByMid" resultMap="InventoryMap" parameterType="integer">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
FROM findInventory WHERE mid =#{mid}
</select>
<select id="findInventoryByMidAndDid" resultMap="InventoryMap" parameterType="map">
select
<include refid="allColumnsAndTypeNameOnViewByInventory" />

2
src/main/java/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.java

@ -143,4 +143,6 @@ public interface SplitUnitMapper {
*/
List<SplitInfo> findSplitInfoByMid(Integer mid);
}

2
src/main/java/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.xml

@ -96,7 +96,7 @@
from `split_inventory` si
where 1 = 1
<if test="iid != null and iid != ''">
and si.iid = #{iid},
and si.iid = #{iid}
</if>
<if test="sid != null and sid != ''">
and si.sid = #{sid}

6
src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java

@ -85,4 +85,10 @@ public class ApplicationInRecordP {
*/
private String mdepositoryCode;
/**
* 入库时选中的单位
*/
private String airUnit;
}

13
src/main/java/com/dreamchaser/depository_manage/service/MaterialService.java

@ -110,11 +110,18 @@ public interface MaterialService {
Material findMaterialById(int id);
/**
* 根据物料id查询库存信息
* @param id 库存物料id
* 根据库存id查询库存信息
* @param id 库存id
* @return 库存信息
*/
Inventory findInventoryByMid(int id);
Inventory findInventoryById(int id);
/**
* 根据物料id获取对应库存信息
* @param mid 待查询物料id
* @return
*/
List<Inventory> findInventoryByMid(int mid);
/**
* 根据物料id获取其在对应仓库中的库存数

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

@ -83,4 +83,12 @@ public interface SplitUnitService {
* @return
*/
List<SplitInfo> findSplitInfoByMid(Integer mid);
/**
* 通过物料id与拆单前的计量单位获取对应拆单记录
* @param map 查询条件
* @return
*/
SplitInfo findSplitInfoByMidAndUnit(Map<String,Object> map);
}

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

@ -111,9 +111,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Long producedDate = Long.valueOf(0);
if (map.containsKey("producedDate")) {
Object s = map.get("producedDate");
if(s == null || "".equals(s.toString())){
if (s == null || "".equals(s.toString())) {
producedDate = Long.valueOf(0);
}else{
} else {
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString());
}
}
@ -125,7 +125,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前入库金额
Double amounts = (quantity * price * 100);
// 获取平均价格
Double avgPrice = (material.getAmounts() + amounts) / (material.getQuantity() + quantity);
double avgPrice = 0.0;
if(quantity != 0){
avgPrice = (amounts) / ( quantity);
}else{
avgPrice = price * 100;
}
map.put("amounts", amounts);
map.put("price", price * 100);
String simpleTime = DateUtil.getSimpleTime(new Date());
@ -154,12 +160,18 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
insert.put("amounts", amounts);
insert.put("shelfLife", materialById.getShelfLife());
insert.put("producedDate", producedDate);
insert.put("mid",map.get("mid"));
insert.put("mid", map.get("mid"));
materialMapper.insertInventory(insert);
newMid = ObjectFormatUtil.toInteger(insert.get("id"));
}
// 将新入库的物料id记录下来
map.put("newInMid", newMid);
// 如果包含realQuantity则代表是入库的拆单单位
if(map.containsKey("realQuantity")){
// 将入库数量修改为realQuantity
map.put("quantity",map.get("realQuantity"));
}
return depositoryRecordMapper.insertApplicationInRecord(map);
}
@ -189,7 +201,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.put("state", "待部门负责人审核");
if (mid != null) {
// 获取当前物料
Inventory materialById = materialMapper.findInventoryByMid(mid);
Inventory materialById = materialMapper.findInventoryById(mid);
int amounts = (int) ((materialById.getPrice() / 100) * quantity * 100);
map.put("price", amounts);
Map<String, Object> update = new HashMap<>();
@ -203,7 +215,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Depository depositoryRecordById = depositoryMapper.findDepositoryById(materialById.getDepositoryId());
dname = depositoryRecordById.getDname();
}
Administration company = LinkInterfaceUtil.getCompany(userToken.getMaindeparment(), userToken);
String code = createCode(dname, "outOrderNumber", "out", company.getName());
map.put("code", code);
@ -227,7 +238,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return
*/
@Override
public Map<String,Object> CalculateAllApplicationInCount() {
public Map<String, Object> CalculateAllApplicationInCount() {
// 获取当前时间
long now = System.currentTimeMillis();
@ -238,13 +249,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Long yesterdayTimeForCalc = DateUtil.getYesterdayTimeForCalc();
// 用于查询今天到现在的入库记录
Map<String,Object> mapForToday = new HashMap<>();
mapForToday.put("start",nowTimeForCalc);
mapForToday.put("end",now);
Map<String, Object> mapForToday = new HashMap<>();
mapForToday.put("start", nowTimeForCalc);
mapForToday.put("end", now);
// 用于查询昨天的入库记录
Map<String,Object> mapForYesterday = new HashMap<>();
mapForYesterday.put("start",yesterdayTimeForCalc);
mapForYesterday.put("end",nowTimeForCalc);
Map<String, Object> mapForYesterday = new HashMap<>();
mapForYesterday.put("start", yesterdayTimeForCalc);
mapForYesterday.put("end", nowTimeForCalc);
// 查询今天目前为止的入库
List<ApplicationInRecordP> applicationInRecordPForToday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForToday);
@ -269,27 +280,27 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
for (int i = 0; i < applicationInRecordPForYesterday.size(); i++) {
ApplicationInRecordP applicationInRecordP = applicationInRecordPForYesterday.get(i);
sumForYesterDay += applicationInRecordP.getQuantity();
priceForYesterDay += applicationInRecordP.getPrice() * applicationInRecordP.getQuantity() ;
priceForYesterDay += applicationInRecordP.getPrice() * applicationInRecordP.getQuantity();
}
Map<String,Object> result = new HashMap<>();
result.put("total",sumForToday);
Map<String, Object> result = new HashMap<>();
result.put("total", sumForToday);
Double ratioForCount = 0.0;
Double ratioForPrice = 0.0;
if(Double.compare(sumForYesterDay,0.0) != 0){
if (Double.compare(sumForYesterDay, 0.0) != 0) {
ratioForCount = ((sumForToday - sumForYesterDay) / Double.parseDouble(sumForYesterDay.toString()));
}
if(Double.compare(priceForYesterDay,0.0) != 0){
if (Double.compare(priceForYesterDay, 0.0) != 0) {
ratioForPrice = (priceForToday - priceForYesterDay) / Double.parseDouble(priceForYesterDay.toString());
}
BigDecimal bgForSum = new BigDecimal(ratioForCount);
BigDecimal bgForPrice = new BigDecimal(ratioForPrice);
ratioForCount = bgForSum.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
ratioForPrice = bgForPrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
result.put("ratioForSum",ratioForCount * 100);
result.put("ratioForPrice",ratioForPrice * 100);
result.put("ratioForSum", ratioForCount * 100);
result.put("ratioForPrice", ratioForPrice * 100);
BigDecimal bgPrice = new BigDecimal(priceForToday / 100);
priceForToday = bgPrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
result.put("price",priceForToday);
result.put("price", priceForToday);
return result;
}
@ -300,7 +311,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return
*/
@Override
public Map<String,Object> CalculateAllApplicationOutCount(String state) {
public Map<String, Object> CalculateAllApplicationOutCount(String state) {
// 获取昨天出库订单
// 获取当前时间
long now = System.currentTimeMillis();
@ -311,27 +322,27 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Long yesterdayTimeForCalc = DateUtil.getYesterdayTimeForCalc();
// 用于查询今天到现在的出库记录
Map<String,Object> mapForToday = new HashMap<>();
mapForToday.put("start",nowTimeForCalc);
mapForToday.put("end",now);
Map<String, Object> mapForToday = new HashMap<>();
mapForToday.put("start", nowTimeForCalc);
mapForToday.put("end", now);
// 用于查询昨天的出库记录
Map<String,Object> mapForYesterday = new HashMap<>();
mapForYesterday.put("start",yesterdayTimeForCalc);
mapForYesterday.put("end",nowTimeForCalc);
Map<String, Object> mapForYesterday = new HashMap<>();
mapForYesterday.put("start", yesterdayTimeForCalc);
mapForYesterday.put("end", nowTimeForCalc);
// 用于最终的结果
Map<String,Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>();
// 获取今天的额度
Double priceForToday = 0.0;
// 获取今天的总数
Integer countForToday = 0;
Integer countForToday = 0;
// 获取昨天的额度
Double priceForYesterday = 0.0;
// 获取昨天的总数
Integer countForYesterday = 0;
Integer countForYesterday = 0;
if (state.isEmpty()) {
// 获取今天为止的出库记录
List<ApplicationOutRecordP> applicationOutRecordPForToday = depositoryRecordMapper.findApplicationOutRecordPForAPeriodOfTime(mapForToday);
@ -342,7 +353,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 昨天的出库记录数
int yesterdaySize = applicationOutRecordPForYesterday.size();
if(todaySize > 0) {
if (todaySize > 0) {
// 定义线程用于计算今天的记录
ExecutorService exsForToday = Executors.newFixedThreadPool(todaySize);
// 结果集
@ -361,17 +372,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
for (int i = 0; i < todaySize; i++) {
Object o = null;
try {
o = completionServiceForToday.take().get();
o = completionServiceForToday.take().get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
countForToday += ObjectFormatUtil.toInteger(((Map<String,Object>)o).get("count"));
priceForToday += Double.parseDouble(((Map<String,Object>)o).get("price").toString());
countForToday += ObjectFormatUtil.toInteger(((Map<String, Object>) o).get("count"));
priceForToday += Double.parseDouble(((Map<String, Object>) o).get("price").toString());
}
}
if(yesterdaySize > 0){
if (yesterdaySize > 0) {
// 定义线程用于计算昨天的记录
ExecutorService exsForYesterday = Executors.newFixedThreadPool(yesterdaySize);
// 结果集
@ -389,26 +400,26 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
for (int i = 0; i < yesterdaySize; i++) {
Object o = null;
try {
o = completionServiceForYesterday.take().get();
o = completionServiceForYesterday.take().get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
countForYesterday += ObjectFormatUtil.toInteger(((Map<String,Object>)o).get("count"));
priceForYesterday += Double.parseDouble(((Map<String,Object>)o).get("price").toString());
countForYesterday += ObjectFormatUtil.toInteger(((Map<String, Object>) o).get("count"));
priceForYesterday += Double.parseDouble(((Map<String, Object>) o).get("price").toString());
}
}
// 设置今天的额度
result.put("price",priceForToday);
result.put("count",countForToday);
result.put("price", priceForToday);
result.put("count", countForToday);
Double ratioForCount = 0.0;
Double ratioForPrice = 0.0;
if(Double.compare(countForYesterday,0.0) != 0){
if (Double.compare(countForYesterday, 0.0) != 0) {
ratioForCount = ((countForToday - countForYesterday) / Double.parseDouble(countForYesterday.toString()));
}
if(Double.compare(priceForYesterday,0.0) != 0){
if (Double.compare(priceForYesterday, 0.0) != 0) {
ratioForPrice = (priceForToday - priceForYesterday) / Double.parseDouble(priceForYesterday.toString());
}
BigDecimal bgForSum = new BigDecimal(ratioForCount);
@ -416,9 +427,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
ratioForCount = bgForSum.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
ratioForPrice = bgForPrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// 获取数量比值
result.put("radioForCount",ratioForCount * 100);
result.put("radioForCount", ratioForCount * 100);
// 获取金额比值
result.put("radioForPrice",ratioForPrice * 100);
result.put("radioForPrice", ratioForPrice * 100);
} else {
// 如果获取已经出库的数量(今天)
List<ApplicationOutRecordMin> applicationOutMinForCompleteForToday = depositoryRecordMapper.findApplicationOutMinForComplete(mapForToday);
@ -426,9 +437,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
List<ApplicationOutRecordMin> applicationOutMinForCompleteForYesterday = depositoryRecordMapper.findApplicationOutMinForComplete(mapForYesterday);
for (int i = 0; i < applicationOutMinForCompleteForToday.size(); i++) {
ApplicationOutRecordMin recordMin = applicationOutMinForCompleteForToday.get(i);
countForToday += recordMin.getQuantity();
countForToday += recordMin.getQuantity();
// 获取当前出库物料
Inventory materialById = materialMapper.findInventoryByMid(recordMin.getMid());
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 计算当前出库金额
double price_out = materialById.getPrice() * recordMin.getQuantity();
BigDecimal bg = new BigDecimal(price_out / 100);
@ -438,7 +449,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
for (int i = 0; i < applicationOutMinForCompleteForYesterday.size(); i++) {
ApplicationOutRecordMin recordMin = applicationOutMinForCompleteForYesterday.get(i);
countForYesterday += recordMin.getQuantity();
countForYesterday += recordMin.getQuantity();
// 获取当前出库物料
Material materialById = materialMapper.findMaterialById(recordMin.getMid());
// 计算当前出库金额
@ -448,14 +459,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
priceForYesterday += price_out;
}
// 设置今天的额度
result.put("price",priceForToday);
result.put("count",countForToday);
result.put("price", priceForToday);
result.put("count", countForToday);
Double ratioForCount = 0.0;
Double ratioForPrice = 0.0;
if(Double.compare(countForYesterday,0.0) != 0){
ratioForCount = ((countForToday - countForYesterday) / Double.parseDouble(countForYesterday.toString()));
if (Double.compare(countForYesterday, 0.0) != 0) {
ratioForCount = ((countForToday - countForYesterday) / Double.parseDouble(countForYesterday.toString()));
}
if(Double.compare(priceForYesterday,0.0) != 0){
if (Double.compare(priceForYesterday, 0.0) != 0) {
ratioForPrice = (priceForToday - priceForYesterday) / Double.parseDouble(priceForYesterday.toString());
}
BigDecimal bgForSum = new BigDecimal(ratioForCount);
@ -463,9 +474,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
ratioForCount = bgForSum.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
ratioForPrice = bgForPrice.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// 获取数量比值
result.put("radioForCount",ratioForCount * 100);
result.put("radioForCount", ratioForCount * 100);
// 获取金额比值
result.put("radioForPrice",ratioForPrice * 100);
result.put("radioForPrice", ratioForPrice * 100);
}
return result;
}
@ -473,16 +484,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
/**
* 用于计算当前主记录下的总额与数量
*/
class CalcApplicationOutInfo implements Callable<Object>{
class CalcApplicationOutInfo implements Callable<Object> {
ApplicationOutRecordP mainRecord;
CalcApplicationOutInfo( ApplicationOutRecordP mainRecord){
CalcApplicationOutInfo(ApplicationOutRecordP mainRecord) {
this.mainRecord = mainRecord;
}
@Override
public Object call() throws Exception {
Map<String,Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>();
// 获取当前订单的子订单
List<ApplicationOutRecordMin> minList = depositoryRecordMapper.findApplicationOutRecordMinByParent(mainRecord.getId());
// 额度
@ -491,17 +503,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Integer count = 0;
for (int i = 0; i < minList.size(); i++) {
ApplicationOutRecordMin recordMin = minList.get(i);
count +=recordMin.getQuantity();
count += recordMin.getQuantity();
// 获取当前出库物料
Inventory materialById = materialMapper.findInventoryByMid(recordMin.getMid());
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 计算当前出库金额
double price_out = materialById.getPrice() * recordMin.getQuantity();
BigDecimal bg = new BigDecimal(price_out / 100);
price_out = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
price += price_out;
}
result.put("count",count);
result.put("price",price);
result.put("count", count);
result.put("price", price);
return result;
}
}
@ -525,6 +537,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取当前物料基本信息
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Material materialById = materialMapper.findMaterialById(mid);
String unit = (String) map.get("unit");
if("-1".equals(unit)){
map.put("unit",materialById.getUnit());
}
if (placeById.getMax() - placeById.getQuantity() > quantity) {
// 如果当前库位还能存放
// 入库
@ -543,9 +559,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (map.containsKey("producedDate")) {
Long producedDate = Long.valueOf(0);
Object s = map.get("producedDate");
if(s == null || "".equals(s.toString())){
if (s == null || "".equals(s.toString())) {
producedDate = Long.valueOf(0);
}else{
} else {
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString());
insertProducedDate.put("producedDate", producedDate);
}
@ -553,13 +569,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 查找当前物料id与生产日期的对应关系
MaterialAndProducedDate materialAndProducedDateByMidAndProducedDate = materialMapper.findMaterialAndProducedDateByMidAndProducedDate(insertProducedDate);
if(materialAndProducedDateByMidAndProducedDate != null){
if (materialAndProducedDateByMidAndProducedDate != null) {
// 增加当前数量
materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + quantity);
materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + quantity);
// 修改
materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate);
}else {
} else {
insertProducedDate.put("quantity", quantity);
insertProducedDate.put("inventory", quantity);
insertProducedDate.put("expendnum", 0);
@ -663,9 +679,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
@Override
public Integer insertApplicationOutMin(Map<String, Object> map) {
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Inventory materialById = materialMapper.findInventoryByMid(mid);
Inventory materialById = materialMapper.findInventoryById(mid);
map.put("depositoryId", materialById.getDepositoryId());
map.put("trueOut",0);
map.put("trueOut", 0);
return depositoryRecordMapper.insertApplicationOutRecordMin(map);
}
@ -736,7 +752,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取子订单中对应的库存id
Integer mid = applicationOutMinById.getMid();
// 获取库存信息
Inventory inventory = materialMapper.findInventoryByMid(mid);
Inventory inventory = materialMapper.findInventoryById(mid);
// 获取子订单对应的主订单
ApplicationOutRecordP record = depositoryRecordMapper.findApplicationOutRecordPById(applicationOutMinById.getParentId());
// 设置标志位
@ -826,11 +842,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// redisTemplate.opsForHash().put(redisMinRecordKey,"manager",userByPort.getId().toString());
// 修改当前已经出库的数量
applicationOutMinById.setTrueOut(trueOut+applicationOutMinById.getTrueOut());
if(applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut() > 0){
applicationOutMinById.setTrueOut(trueOut + applicationOutMinById.getTrueOut());
if (applicationOutMinById.getQuantity() - applicationOutMinById.getTrueOut() > 0) {
// 如果当前子订单中的物料并未完全出库
depositoryRecordMapper.updateApplicationOutRecordMin(applicationOutMinById);
}else{
} else {
// 如果完成出库
// 获取当前订单中所有管理员
@ -1079,7 +1095,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 获取对应的物料编号
Integer mid = applicationOutRecordMin.getMid();
// 获取物料信息
Inventory materialById = materialMapper.findInventoryByMid(mid);
Inventory materialById = materialMapper.findInventoryById(mid);
// 获取该物料所处仓库的仓库管理员
List<Integer> userIdByDid = new ArrayList<>();
userIdByDid = roleService.findUserIdByDid(materialById.getDepositoryId());
@ -1157,8 +1173,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 将当前redis中存储的spno删除
redisTemplate.delete(spNo);
}
}
else {
} else {
// 如果是部门负责人
String departmentheadTime = recordP.getDepartmentheadTime();
@ -1215,7 +1230,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
public Integer transferApply(Map<String, Object> map, UserByPort userByPort) {
Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Double quantity = Double.parseDouble((String) map.get("quantity"));
Inventory material = materialMapper.findInventoryByMid(mid);
Inventory material = materialMapper.findInventoryById(mid);
map.put("depositoryId", material.getDepositoryId());
map.put("mid", mid);
map.put("state", "待部门负责人审核");
@ -1260,7 +1275,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
map.remove("id");
map.put("parentId", id);
}
map.put("trueOut",0);
map.put("trueOut", 0);
return depositoryRecordMapper.insertApplicationOutRecordMin(map);
}
@ -1746,7 +1761,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
TransferRecord transferRecor = transferRecordMapper.findTransferRecordById(recordMin.getTransferId());
Integer mid = transferRecor.getMid();
// 获取库存信息
Inventory material = materialMapper.findInventoryByMid(mid);
Inventory material = materialMapper.findInventoryById(mid);
param.put("mcode", material.getCode());
param.put("depositoryId", transferRecor.getToId());
List<Inventory> materiallist = materialMapper.findInventory(param);
@ -1768,7 +1783,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
insert.put("quantity", quantity);
insert.put("amounts", quantity * material.getPrice());
insert.put("depositoryCode", material.getDepositoryCode());
insert.put("producedDate",material.getProducedDate());
insert.put("producedDate", material.getProducedDate());
materialMapper.insertInventory(insert);
// 查询该记录
@ -1930,7 +1945,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
/**
* 查询当前仓库的入库记录
* @param depositoryId 待查询仓库id
*
* @param depositoryId 待查询仓库id
* @return
*/
@Override
@ -1940,6 +1956,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
/**
* 查询当前仓库的出库记录
*
* @param depositoryId 待查询仓库id
* @return
*/
@ -2126,8 +2143,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return
*/
@Override
public Map<String,Object> CalculateAllApplicationInAll() {
Map<String,Object> result = new HashMap<>();
public Map<String, Object> CalculateAllApplicationInAll() {
Map<String, Object> result = new HashMap<>();
List<ApplicationInRecordP> applicationInRecordPAll = depositoryRecordMapper.findApplicationInRecordPAll();
Double sum = 0.0;
Integer count = 0;
@ -2139,8 +2156,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
}
BigDecimal bg = new BigDecimal(sum);
sum = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
result.put("price",sum);
result.put("count",count);
result.put("price", sum);
result.put("count", count);
return result;
}

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

@ -2,6 +2,7 @@ package com.dreamchaser.depository_manage.service.impl;
import com.alibaba.fastjson.JSON;
import com.dreamchaser.depository_manage.entity.*;
import com.dreamchaser.depository_manage.mapper.MaterialMapper;
import com.dreamchaser.depository_manage.pojo.InventoryP;
import com.dreamchaser.depository_manage.pojo.MaterialP;
import com.dreamchaser.depository_manage.service.ExcelService;
@ -40,6 +41,9 @@ public class ExcelServiceImpl implements ExcelService {
@Autowired
PlaceService placeService;
@Autowired
MaterialMapper materialMapper;
/**
* 用于导入物料名称
*
@ -299,31 +303,40 @@ public class ExcelServiceImpl implements ExcelService {
Material material = materialService.findMaterialByMnameAndVersion(insert);
if(material == null)
{
material = materialMapper.findMaterialByCondition(insert).get(0);
}
// 添加库存记录
Integer depositoryId = excelInfoByInventory.getDepositoryId();
insert.put("tempPlaceCode", excelInfoByInventory.getDepositoryCode());
insert.put("quantity", String.valueOf(ObjectFormatUtil.toInteger(excelInfoByInventory.getQuantity())));
// 如果模板中总金额未填写
if (excelInfoByInventory.getAmounts() == null || "".equals(excelInfoByInventory.getAmounts())) {
// 求均值
// 总金额
Double amounts = Double.parseDouble(excelInfoByInventory.getPrice()) * 100 * Double.parseDouble(excelInfoByInventory.getQuantity());
insert.put("amounts", amounts);
// 保留两位
Double avgPrice = Double.parseDouble(excelInfoByInventory.getQuantity());
BigDecimal bg = new BigDecimal(avgPrice);
avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
insert.put("price", String.valueOf(avgPrice));
} else {
// 求均值
insert.put("amounts", Double.parseDouble(excelInfoByInventory.getAmounts()) * 100);
Double avgPrice = ( Double.parseDouble(excelInfoByInventory.getAmounts()) * 100) / ((Double.parseDouble(excelInfoByInventory.getQuantity()) ));
// 保留两位
BigDecimal bg = new BigDecimal(avgPrice);
avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
insert.put("price", String.valueOf(avgPrice));
if(excelInfoByInventory.getPrice() != null && "".equals(excelInfoByInventory.getPrice())) {
// 如果模板中总金额未填写
if (excelInfoByInventory.getAmounts() == null || "".equals(excelInfoByInventory.getAmounts())) {
// 求均值
// 总金额
Double amounts = Double.parseDouble(excelInfoByInventory.getPrice()) * 100 * Double.parseDouble(excelInfoByInventory.getQuantity());
insert.put("amounts", amounts);
// 保留两位
Double avgPrice = Double.parseDouble(excelInfoByInventory.getQuantity());
BigDecimal bg = new BigDecimal(avgPrice);
avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
insert.put("price", String.valueOf(avgPrice));
} else {
// 求均值
insert.put("amounts", Double.parseDouble(excelInfoByInventory.getAmounts()) * 100);
Double avgPrice = (Double.parseDouble(excelInfoByInventory.getAmounts()) * 100) / ((Double.parseDouble(excelInfoByInventory.getQuantity())));
// 保留两位
BigDecimal bg = new BigDecimal(avgPrice);
avgPrice = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
insert.put("price", String.valueOf(avgPrice));
}
}else{
insert.put("price",0);
insert.put("amounts",0);
}
insert.put("depositoryId", depositoryId);
insert.put("depositoryCode", excelInfoByInventory.getDepositoryCode());

42
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java

@ -379,13 +379,13 @@ public class MaterialServiceImpl implements MaterialService {
}
/**
* 根据物料id查询库存信息
* @param id 库存物料id
* 根据库存id查询库存信息
* @param id 库存id
* @return 库存信息
*/
@Override
public Inventory findInventoryByMid(int id) {
Inventory material = materialMapper.findInventoryByMid(id);
public Inventory findInventoryById(int id) {
Inventory material = materialMapper.findInventoryById(id);
MaterialType materialTypeByOldId = materialTypeMapper.findMaterialTypeByOldId(material.getMaterialTypeId());
material.setTypeName(materialTypeByOldId.getTname());
material.setPrice(material.getPrice() / 100);
@ -393,6 +393,23 @@ public class MaterialServiceImpl implements MaterialService {
return material;
}
/**
* 根据物料id获取对应库存信息
* @param mid 待查询物料id
* @return
*/
@Override
public List<Inventory> findInventoryByMid(int mid) {
List<Inventory> inventoryByMid = materialMapper.findInventoryByMid(mid);
for (Inventory inventory : inventoryByMid) {
MaterialType materialTypeByOldId = materialTypeMapper.findMaterialTypeByOldId(inventory.getMaterialTypeId());
inventory.setTypeName(materialTypeByOldId.getTname());
inventory.setPrice(inventory.getPrice() / 100);
inventory.setAmounts(inventory.getAmounts() / 100);
}
return inventoryByMid;
}
/**
* 根据物料id获取其在对应仓库中的库存数
@ -725,9 +742,12 @@ public class MaterialServiceImpl implements MaterialService {
*/
@Override
public Integer insertInventoryForImport(Map<String, Object> map) {
if (map.containsKey("quantity") && map.containsKey("price")) {
if (map.containsKey("quantity")) {
int quantity = (int) Math.round(Double.parseDouble(map.get("quantity").toString()));
int price = (int) (Double.parseDouble(map.get("price").toString()));
int price = 0;
if(map.containsKey("price")){
price = (int) (Double.parseDouble(map.get("price").toString()));
}
map.put("price", price);
map.put("amounts", quantity * price);
}
@ -743,7 +763,11 @@ public class MaterialServiceImpl implements MaterialService {
// 如果该物料存在
Inventory material = inventory.get(0);
Double price = (Double.parseDouble(map.get("price").toString())) / 100;
Double price = 0.0;
if(map.containsKey("price")){
price = (Double.parseDouble(map.get("price").toString())) / 100;
}
int quantity = (int) Math.round(Double.parseDouble(map.get("quantity").toString()));
// 获取当前入库金额
Double amounts = (quantity * price * 100);
@ -868,7 +892,7 @@ public class MaterialServiceImpl implements MaterialService {
List<MaterialAndBarCode> materialByBarCodeByCondition = materialMapper.findMaterialByBarCodeByCondition(map);
if (materialByBarCodeByCondition.size() > 0) {
MaterialAndBarCode materialAndBarCode = materialByBarCodeByCondition.get(0);
Inventory inventoryByMid = materialMapper.findInventoryByMid(materialAndBarCode.getIid());
Inventory inventoryByMid = materialMapper.findInventoryById(materialAndBarCode.getIid());
materialAndBarCode.setPrice(inventoryByMid.getPrice() / 100);
return materialAndBarCode;
}
@ -1184,7 +1208,7 @@ public class MaterialServiceImpl implements MaterialService {
public Integer editPlaceMaterial(Map<String, Object> map) {
// 获取要转移的库存信息
Integer id = ObjectFormatUtil.toInteger(map.get("mid"));
Inventory inventoryByMid = materialMapper.findInventoryByMid(id);
Inventory inventoryByMid = materialMapper.findInventoryById(id);
// 获取当前转移之前的库位
Integer fromPlaceId = ObjectFormatUtil.toInteger(map.get("fromPlaceId"));
Place fromPlace = placeService.findPlaceById(fromPlaceId);

22
src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java

@ -76,7 +76,7 @@ public class QyWxOperationService {
// 获取子订单信息
ApplicationOutRecordMin applicationOutRecordMin = applicationOutRecordMinByParent.get(i);
// 获取当前申请物料
Inventory materialById = materialMapper.findInventoryByMid(applicationOutRecordMin.getMid());
Inventory materialById = materialMapper.findInventoryById(applicationOutRecordMin.getMid());
// 获取当前物料所在仓库
Depository depositoryRecordById = depositoryMapper.findDepositoryById(materialById.getDepositoryId());
sumQuantity.append(applicationOutRecordMin.getQuantity()).append(",");
@ -293,7 +293,7 @@ public class QyWxOperationService {
// 获取子订单信息
StockTakingChildP childP = minRecordList.get(i);
// 获取当前申请物料
Inventory materialById = materialMapper.findInventoryByMid(childP.getMid());
Inventory materialById = materialMapper.findInventoryById(childP.getMid());
// 设置物料名称
mname.append(materialById.getMname()).append(",");
// 设置盘点数量
@ -543,7 +543,7 @@ public class QyWxOperationService {
// 获取子订单信息
StockTakingChildP childP = minRecordList.get(i);
// 获取当前申请物料
Inventory materialById = materialMapper.findInventoryByMid(childP.getMid());
Inventory materialById = materialMapper.findInventoryById(childP.getMid());
// 设置物料名称
mname.append(materialById.getMname()).append(",");
// 设置盘点数量
@ -773,7 +773,7 @@ public class QyWxOperationService {
for (ApplicationOutRecordMin recordMin : applicationOutRecordMinByParent) {
// 获取子订单信息
// 获取申请物料信息
Inventory materialById = materialMapper.findInventoryByMid(recordMin.getMid());
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 获取仓库信息
Depository depositoryRecordById = depositoryMapper.findDepositoryById(recordMin.getDepositoryId());
// 获取处理人信息
@ -855,7 +855,7 @@ public class QyWxOperationService {
StockTakingChildP minRecord = stockTakingMapper.selectStockTakingChildPById(minId);
// 获取当前物料
Inventory material = materialMapper.findInventoryByMid(minRecord.getMid());
Inventory material = materialMapper.findInventoryById(minRecord.getMid());
// 设置盘点结果
String takingResult = minRecord.getTakingResult();
@ -959,7 +959,7 @@ public class QyWxOperationService {
StockTakingChildP minRecord = stockTakingMapper.selectStockTakingChildPById(minId);
// 获取当前物料
Inventory material = materialMapper.findInventoryByMid(minRecord.getMid());
Inventory material = materialMapper.findInventoryById(minRecord.getMid());
// 获取转移前的库位
@ -1056,7 +1056,7 @@ public class QyWxOperationService {
StockTakingChildP minRecord = stockTakingMapper.selectStockTakingChildPById(minId);
// 获取当前物料
Inventory material = materialMapper.findInventoryByMid(minRecord.getMid());
Inventory material = materialMapper.findInventoryById(minRecord.getMid());
// 获取转移数量
@ -1216,7 +1216,7 @@ public class QyWxOperationService {
List<TemplateCard_horizontal_content> horizontalContentList = new ArrayList<>();
// 获取申请物料信息
Inventory materialById = materialMapper.findInventoryByMid(recordMin.getMid());
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 获取仓库信息
Depository depositoryRecordById = depositoryMapper.findDepositoryById(recordMin.getDepositoryId());
// 设至二级标题
@ -1484,7 +1484,7 @@ public class QyWxOperationService {
// 获取明细信息
ApplicationOutRecordMin recordMin = minRecordList.get(i);
// 获取当前出库物料
Inventory materialById = materialMapper.findInventoryByMid(recordMin.getMid());
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 获取当前物料所在仓库
Depository depositoryById = depositoryMapper.findDepositoryById(recordMin.getDepositoryId());
@ -1765,7 +1765,7 @@ public class QyWxOperationService {
// 获取明细信息
ApplicationOutRecordMin recordMin = minRecordList.get(i);
// 获取当前出库物料
Inventory materialById = materialMapper.findInventoryByMid(recordMin.getMid());
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid());
// 获取当前物料所在仓库
Depository depositoryById = depositoryMapper.findDepositoryById(recordMin.getDepositoryId());
@ -2108,7 +2108,7 @@ public class QyWxOperationService {
StockTakingChildP minRecord = minRecordList.get(i);
// 获取当前盘点物料信息
Inventory materialById = materialMapper.findInventoryByMid(minRecord.getMid());
Inventory materialById = materialMapper.findInventoryById(minRecord.getMid());
Map<String,Object> detail_list = new HashMap<>();

110
src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java

@ -4,15 +4,13 @@ import com.dreamchaser.depository_manage.entity.Inventory;
import com.dreamchaser.depository_manage.entity.SplitInfo;
import com.dreamchaser.depository_manage.entity.SplitInventory;
import com.dreamchaser.depository_manage.exception.MyException;
import com.dreamchaser.depository_manage.mapper.DepositoryMapper;
import com.dreamchaser.depository_manage.mapper.MaterialMapper;
import com.dreamchaser.depository_manage.mapper.PlaceMapper;
import com.dreamchaser.depository_manage.mapper.SplitUnitMapper;
import com.dreamchaser.depository_manage.mapper.*;
import com.dreamchaser.depository_manage.pojo.SplitInfoP;
import com.dreamchaser.depository_manage.service.DepositoryRecordService;
import com.dreamchaser.depository_manage.service.MaterialService;
import com.dreamchaser.depository_manage.service.SplitUnitService;
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil;
import com.sun.mail.imap.protocol.ID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -42,6 +40,9 @@ public class SplitUnitServiceImpl implements SplitUnitService {
@Autowired
DepositoryRecordService depositoryRecordService;
@Autowired
DepositoryRecordMapper depositoryRecordMapper;
/**
* 用于添加一条拆单记录
@ -78,11 +79,12 @@ public class SplitUnitServiceImpl implements SplitUnitService {
@Override
@Transactional(rollbackFor = Exception.class)
public Integer addSplitInventory(Map<String, Object> map) {
Map<String,Object> paramForUnit = new HashMap<>();
paramForUnit.put("newUnit",map.get("unit"));
paramForUnit.put("mid",map.get("mid"));
Map<String,Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("mid",map.get("mid"));
paramForSplitInfo.put("newUnit",map.get("unit"));
// 查询当前拆单是否存在
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForUnit);
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 用于存储最终计算结果
Integer result = 0;
@ -92,47 +94,101 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 获取当前操作的库存id
Integer iid = ObjectFormatUtil.toInteger(map.get("iid"));
// 定义库存拆单记录
SplitInventory splitInventory = null;
// 用于存储拆单库存处理操作的数据
Map<String,Object> paramForInsertSplitInventory = new HashMap<>();
paramForInsertSplitInventory.put("iid",iid);
paramForInsertSplitInventory.put("sid",splitInfoForUnit.getId());
// 查询当前库存是否有该拆单的处理记录
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
if(iid != null){
paramForInsertSplitInventory.put("iid",iid);
// 查询当前库存是否有该拆单的处理记录
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
}else{
Map<String, Object> param = new HashMap<>();
param.put("depositoryId", map.get("depositoryId"));
param.put("mid", map.get("mid"));
// 判断该仓库中有无该物物料
List<Inventory> materialByCondition = materialMapper.findInventory(param);
if(materialByCondition.size() > 0){
paramForInsertSplitInventory.put("iid",materialByCondition.get(0).getId());
// 查询当前库存是否有该拆单的处理记录
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
}
}
// 获取要操作的数量
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity"));
if ("in".equals(type)) {
// 如果是入库操作
// 计算处理数量(下取整)
Integer disposeQuantity = ObjectFormatUtil.toInteger(Math.floor(quantity / splitInfoForUnit.getQuantity()));
int disposeQuantity = (int) Math.round(Math.floor(quantity / splitInfoForUnit.getQuantity()));
// 最终存储到拆单处理的数量
double saveQuantity = quantity - disposeQuantity;
double saveQuantity = quantity - disposeQuantity * splitInfoForUnit.getQuantity();
if(splitInventory != null){
// 如果有过记录
// 最终存储数量
int realQuantity = (int) Math.round(saveQuantity) + splitInventory.getSaveQuantity();
if(realQuantity > splitInfoForUnit.getQuantity()){
// 如果当前入库的数量大于拆单规定的进制数量
int quantity_in = realQuantity - (realQuantity % splitInfoForUnit.getQuantity());
disposeQuantity += quantity_in;
realQuantity = realQuantity - quantity_in * splitInfoForUnit.getQuantity();
}
// 设置当前计量单位的库存
splitInventory.setSaveQuantity(ObjectFormatUtil.toInteger(saveQuantity) + splitInventory.getSaveQuantity());
splitInventory.setSaveQuantity(realQuantity);
// 设置当前计量单位的入库数目
splitInventory.setInQuantity(ObjectFormatUtil.toInteger(splitInventory.getInQuantity() + quantity));
splitInventory.setInQuantity((int) Math.round(splitInventory.getInQuantity() + quantity));
splitUnitMapper.updateSplitInventory(splitInventory);
if(disposeQuantity != 0) {
// 用于更改库存的数量
map.put("quantity", String.valueOf(disposeQuantity));
}else{
map.put("quantity", "0");
}
// 实际入库数量
map.put("realQuantity", quantity.toString());
result += depositoryRecordService.applicationInPlace(map);
}else{
// 如果没有记录
if(disposeQuantity != 0) {
// 用于更改库存的数量
map.put("quantity", String.valueOf(disposeQuantity));
}
else{
map.put("quantity", "0");
}
// 实际入库数量
map.put("realQuantity", quantity.toString());
result += depositoryRecordService.applicationInPlace(map);
paramForInsertSplitInventory.put("inQuantity",quantity);
paramForInsertSplitInventory.put("saveQuantity",saveQuantity);
paramForInsertSplitInventory.put("iid",map.get("newInMid"));
splitUnitMapper.addSplitInventory(paramForInsertSplitInventory);
}
map.put("quantity",disposeQuantity);
result += depositoryRecordService.applicationInPlace(map);
} else if ("out".equals(type)) {
// 如果是出库操作
// 设置出库标志位
paramForInsertSplitInventory.put("outFlag",1);
if(splitInventory != null){
// 如果该物料已经有拆单的数据操作
}else{
// 如果没有数据操作
}
}
}
return result;
@ -275,4 +331,16 @@ public class SplitUnitServiceImpl implements SplitUnitService {
public List<SplitInfo> findSplitInfoByMid(Integer mid) {
return splitUnitMapper.findSplitInfoByMid(mid);
}
/**
* 通过物料id与拆单前的计量单位获取对应拆单记录
* @param map 查询条件
* @return
*/
@Override
public SplitInfo findSplitInfoByMidAndUnit(Map<String, Object> map) {
return splitUnitMapper.findSplitInfoByMidAndUnit(map);
}
}

6
src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java

@ -105,7 +105,7 @@ public class StockTakingServiceImpl implements StockTakingService {
List barCodeList = (ArrayList) barCodeListByNoMaterial.get("barCode" + temp);
Map<String, Object> param = new HashMap<>();
param.put("list", barCodeList);
Inventory materialById = materialMapper.findInventoryByMid(mid);
Inventory materialById = materialMapper.findInventoryById(mid);
param.put("code", materialById.getCode());
materialMapper.addBarCodeAndMaterialForMoreOne(param);
}
@ -614,7 +614,7 @@ public class StockTakingServiceImpl implements StockTakingService {
Integer inventory = minRecord.getInventory();
// 获取盘点物料信息
Inventory materialById = materialMapper.findInventoryByMid(minRecord.getMid());
Inventory materialById = materialMapper.findInventoryById(minRecord.getMid());
Map<String, Object> paramForMaterialAndPlace = new HashMap<>();
@ -891,7 +891,7 @@ public class StockTakingServiceImpl implements StockTakingService {
Integer inventory = minRecord.getInventory();
Inventory materialById = materialMapper.findInventoryByMid(minRecord.getMid());
Inventory materialById = materialMapper.findInventoryById(minRecord.getMid());
Map<String, Object> paramForMaterialAndPlace = new HashMap<>();
paramForMaterialAndPlace.put("mid", materialById.getId());

85
src/main/resources/templates/pages/application/application-in.html

@ -39,7 +39,6 @@
}
</style>
@ -114,7 +113,7 @@
<div class="layui-form-item">
<label class="layui-form-label">物料单价:</label>
<div class="layui-input-block">
<input name="price" type="number" placeholder="请填写入物料单价" value=""
<input name="price" type="number" placeholder="请填写入物料单价" value="" id="price"
class="layui-input" lay-verify="number">
</div>
</div>
@ -128,9 +127,9 @@
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id="unit" name="unit">
<select id="unit" name="unit">
</select>
</select>
</div>
</div>
<div class="layui-form-item">
@ -357,7 +356,7 @@
id="openSonByMaterial" lay-verify="required" onblur="selectMaterialByName(this)"/>
<i class="layui-icon layui-icon-search" style="display: inline" id="selectMaterial" onclick="selectMaterial(this)"></i>
</div>
<input type="text" name=` + "mid" + NewIdNumber + ` class="layui-input" id="mid"
<input type="text" name=` + "mid" + NewIdNumber + ` class="layui-input" id=`+"mid"+NewIdNumber+`
style="display: none" lay-verify="required" />
</div>
</div>
@ -394,7 +393,7 @@
<div class="layui-form-item">
<label class="layui-form-label">物料单价:</label>
<div class="layui-input-block">
<input name=` + "price" + NewIdNumber + ` type="number" placeholder="请填写入物料单价" value=""
<input name=` + "price" + NewIdNumber + ` type="number" placeholder="请填写入物料单价" id=`+"price"+NewIdNumber+`
class="layui-input" lay-verify="number" >
</div>
</div>
@ -408,7 +407,7 @@
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id=`+"unit"+NewIdNumber+` name=`+"unit"+NewIdNumber+` style="border-style: solid;border-radius: 0 2px 2px 0">
<select id=` + "unit" + NewIdNumber + ` name=` + "unit" + NewIdNumber + ` style="border-style: solid;border-radius: 0 2px 2px 0">
</select>
</div>
@ -517,7 +516,7 @@
priceValue.value = "";
obj.value = "";
$("#barCode" + idNumber).empty();
$("#unit"+idNumber).empty();
$("#unit" + idNumber).empty();
form.render();
} else {
@ -530,12 +529,12 @@
if (barCode.length > 0) {
barCode.empty();
}
var unit = $("#unit"+idNumber);
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit"+idNumber).append(new Option(d.unit,d.unit));
$("#unit" + idNumber).append(new Option(d.unit, "-1"));
var unitList = d["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit"+idNumber).append(new Option(unitList[i].newUnit,unitList[i].id));
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
if (materialAndBarCodeList.length > 0) {
@ -647,8 +646,6 @@
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
} else {
console.log(1)
}
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
@ -658,6 +655,14 @@
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
}
});
}
@ -700,6 +705,7 @@
materialName.value = "";
return false;
} else {
var idNumber = materialId.name.split("mid")[1];
var material = d.data[0];
materialName.value = material.mname;
materialId.value = material.mid;
@ -712,6 +718,15 @@
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
}
}
});
@ -803,6 +818,14 @@
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(data.unit, "-1"));
var unitList = data["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
}
}
@ -872,6 +895,15 @@
form.render();
}
form.render();
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
} else {
// 如果没有对应关系
layer.msg("对于编码:" + result + ",并未发现对应的物料", {
@ -961,7 +993,32 @@
})
}
})
}
};
form.on('select()', function (data) {
let elem = data.elem; //得到select原始DOM对象
let elemId = elem.id;
if(elemId.indexOf("unit") === 0){
// 如果进行选择的是计量单位
let id = elemId.split("unit")[1];
let mid = $("#mid"+id).val();
let unit = data.value;
let req = {};
req.newUnit = unit;
req.mid = mid;
$.ajax({
url:"/split/calcPriceForSplit",
data:JSON.stringify(req),
dataType:"json",
type:"post",
contentType: "application/json;charset=utf-8",
success:function (res) {
let data = res.data;
$("#price"+id).val(data);
}
});
}
});
})
</script>

2
src/main/resources/templates/pages/application/form-step-look.html

@ -40,7 +40,7 @@
</tr>
<tr>
<td>计量单位</td>
<td id="munit" th:text="${record.getMunit()}">外芯仓库</td>
<td id="airunit" th:text="${record.getAirUnit()}">外芯仓库</td>
</tr>
<tr>
<td>数量</td>

2
src/main/resources/templates/pages/depository/table-in.html

@ -141,6 +141,8 @@
{type: "checkbox", width: 50},
{field: 'aircode', width: 150, title: '提交编码', sort: true},
{field: 'mname', width: 150, title: '物料名称'},
{field: 'mversion', width: 150, title: '规格型号'},
{field: 'airUnit', width: 100, title: '计量单位'},
{field: 'mcode', width: 150, title: '存货编码'},
{field: 'quantity', width: 150, title: '数量', sort: true},
{field: 'price', title: '金额', minWidth: 150, sort: true},

6
src/main/resources/templates/pages/depository/table-stock.html

@ -140,13 +140,13 @@
{field: 'code', width: 200, title: '存货编码'},
{field: 'typeName', width: 200, title: '物料类型'},
{field: 'quantity', width: 200, title: '数量', sort: true},
{field: 'unit', width: 200, title: '计量单位'},
{field: 'depositoryName', width: 200, title: '仓库名称'},
{field: 'depositoryCode', width: 200, title: '仓库编码'},
{title: '所处库位', width: 200, templet: '#selectManager', align: "center"},
{field: 'warningCount', width: 200, title: '待过期数量', sort: true},
{field: 'price', title: '单价', width: 200, sort: true},
{field: 'amounts', title: '总金额', width: 200, sort: true},
{field: 'unit', width: 200, title: '计量单位'},
{field: 'texture', width: 200, title: '材质',},
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
]
@ -169,8 +169,8 @@
}
}
//
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i+1) + ")").children()[8];
// 所处库位
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i+1) + ")").children()[9];
var aItem = placeCodeItem.childNodes[0];
for (let k = 0; k < placeCode.length; k++) {
if(placeCode[k] !== ""){

3
src/test/java/com/dreamchaser/depository_manage/TestForOther.java

@ -23,9 +23,6 @@ public class TestForOther {
@Test
public void Test() throws IOException {
Double a = 12.5;
Integer b = 10;
System.out.println(a - b);
}
}

19
target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -62,6 +62,8 @@
<result column="mtexture" property="mtexture" jdbcType="VARCHAR" />
<result column="mkingdeecode" property="mkingdeecode" jdbcType="VARCHAR" />
<result column="mdepositoryCode" property="mdepositoryCode" jdbcType="VARCHAR" />
<result column="airUnit" property="airUnit" jdbcType="VARCHAR" />
</resultMap>
<!-- 插入出库记录-->
@ -105,6 +107,7 @@
<result column="parentId" property="parentId" jdbcType="INTEGER" />
<result column="code" property="code" jdbcType="VARCHAR" />
<result column="transferId" property="transferId" jdbcType="INTEGER" />
<result column="unit" property="unit" jdbcType="VARCHAR" />
</resultMap>
<!-- 表查询字段 -->
@ -129,11 +132,11 @@
</sql>
<sql id="allColumnsByApplicationInRecord">
id,mid,quantity,price,applicant_id,applicant_time,code,depository_id,applyRemark
id,mid,quantity,price,applicant_id,applicant_time,code,depository_id,applyRemark,airUnit
</sql>
<sql id="ApplicationInRecordInfo">
airid,mname,quantity,price,tname,applicant_time,aircode,dname,applicant_id,applyRemark,mcode,mversion,munit,mtexture,mkingdeecode,mdepositoryCode
airid,mname,quantity,price,tname,applicant_time,aircode,dname,applicant_id,applyRemark,mcode,mversion,munit,mtexture,mkingdeecode,mdepositoryCode,airUnit
</sql>
<sql id="ApplicationOutRecordInfo">
@ -142,7 +145,7 @@
</sql>
<sql id="ApplicationOutRecordMinInfo">
aorm.id,aorm.mid,aorm.depositoryId,aorm.placeId,aorm.quantity,aorm.code,aorm.checkId,aorm.parentId,aorm.transferId,aorm.trueOut
aorm.id,aorm.mid,aorm.depositoryId,aorm.placeId,aorm.quantity,aorm.code,aorm.checkId,aorm.parentId,aorm.transferId,aorm.trueOut,aorm.unit
</sql>
<!-- 查询所有数据行数 -->
<select id="findCount" resultType="integer">
@ -622,7 +625,7 @@
<!-- 插入一条入库记录-->
<insert id="insertApplicationInRecord" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into application_in_record (id,mid,quantity,price,applicant_id,applicant_time,depository_id,code,applyRemark)
insert into application_in_record (id,mid,quantity,price,applicant_id,applicant_time,depository_id,code,applyRemark,unit)
values(
#{id},
#{mid},
@ -632,7 +635,8 @@
#{applicant_time},
#{depositoryId},
#{code},
#{applyRemark}
#{applyRemark},
#{unit}
)
</insert>
@ -687,7 +691,7 @@
<!-- 插入一条出库子订单-->
<insert id="insertApplicationOutRecordMin" parameterType="map" useGeneratedKeys="true" keyProperty="id">
insert into application_out_record_min (id,mid,quantity,code,depositoryId,placeId,checkId,parentId,transferId,trueOut)
insert into application_out_record_min (id,mid,quantity,code,depositoryId,placeId,checkId,parentId,transferId,trueOut,unit)
values(
#{id},
#{mid},
@ -698,7 +702,8 @@
#{checkId},
#{parentId},
#{transferId},
#{trueOut}
#{trueOut},
#{unit}
)
</insert>

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

@ -229,7 +229,7 @@
AND mname LIKE CONCAT('%', #{mname}, '%')
</if>
<if test="version != null">
and version = #{version}
and version LIKE concat('%',#{version},'%')
</if>
<if test="quantity != null">
AND quantity = #{quantity}
@ -612,12 +612,18 @@
FROM material m WHERE m.id =#{id}
</select>
<select id="findInventoryByMid" resultMap="InventoryMap" parameterType="integer">
<select id="findInventoryById" resultMap="InventoryMap" parameterType="integer">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
FROM findInventory WHERE id =#{mid}
</select>
<select id="findInventoryByMid" resultMap="InventoryMap" parameterType="integer">
SELECT
<include refid="allColumnsAndTypeNameOnViewByInventory" />
FROM findInventory WHERE mid =#{mid}
</select>
<select id="findInventoryByMidAndDid" resultMap="InventoryMap" parameterType="map">
select
<include refid="allColumnsAndTypeNameOnViewByInventory" />

2
target/classes/com/dreamchaser/depository_manage/mapper/SplitUnitMapper.xml

@ -96,7 +96,7 @@
from `split_inventory` si
where 1 = 1
<if test="iid != null and iid != ''">
and si.iid = #{iid},
and si.iid = #{iid}
</if>
<if test="sid != null and sid != ''">
and si.sid = #{sid}

85
target/classes/templates/pages/application/application-in.html

@ -39,7 +39,6 @@
}
</style>
@ -114,7 +113,7 @@
<div class="layui-form-item">
<label class="layui-form-label">物料单价:</label>
<div class="layui-input-block">
<input name="price" type="number" placeholder="请填写入物料单价" value=""
<input name="price" type="number" placeholder="请填写入物料单价" value="" id="price"
class="layui-input" lay-verify="number">
</div>
</div>
@ -128,9 +127,9 @@
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id="unit" name="unit">
<select id="unit" name="unit">
</select>
</select>
</div>
</div>
<div class="layui-form-item">
@ -357,7 +356,7 @@
id="openSonByMaterial" lay-verify="required" onblur="selectMaterialByName(this)"/>
<i class="layui-icon layui-icon-search" style="display: inline" id="selectMaterial" onclick="selectMaterial(this)"></i>
</div>
<input type="text" name=` + "mid" + NewIdNumber + ` class="layui-input" id="mid"
<input type="text" name=` + "mid" + NewIdNumber + ` class="layui-input" id=`+"mid"+NewIdNumber+`
style="display: none" lay-verify="required" />
</div>
</div>
@ -394,7 +393,7 @@
<div class="layui-form-item">
<label class="layui-form-label">物料单价:</label>
<div class="layui-input-block">
<input name=` + "price" + NewIdNumber + ` type="number" placeholder="请填写入物料单价" value=""
<input name=` + "price" + NewIdNumber + ` type="number" placeholder="请填写入物料单价" id=`+"price"+NewIdNumber+`
class="layui-input" lay-verify="number" >
</div>
</div>
@ -408,7 +407,7 @@
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id=`+"unit"+NewIdNumber+` name=`+"unit"+NewIdNumber+` style="border-style: solid;border-radius: 0 2px 2px 0">
<select id=` + "unit" + NewIdNumber + ` name=` + "unit" + NewIdNumber + ` style="border-style: solid;border-radius: 0 2px 2px 0">
</select>
</div>
@ -517,7 +516,7 @@
priceValue.value = "";
obj.value = "";
$("#barCode" + idNumber).empty();
$("#unit"+idNumber).empty();
$("#unit" + idNumber).empty();
form.render();
} else {
@ -530,12 +529,12 @@
if (barCode.length > 0) {
barCode.empty();
}
var unit = $("#unit"+idNumber);
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit"+idNumber).append(new Option(d.unit,d.unit));
$("#unit" + idNumber).append(new Option(d.unit, "-1"));
var unitList = d["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit"+idNumber).append(new Option(unitList[i].newUnit,unitList[i].id));
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
if (materialAndBarCodeList.length > 0) {
@ -647,8 +646,6 @@
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
} else {
console.log(1)
}
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
@ -658,6 +655,14 @@
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
}
});
}
@ -700,6 +705,7 @@
materialName.value = "";
return false;
} else {
var idNumber = materialId.name.split("mid")[1];
var material = d.data[0];
materialName.value = material.mname;
materialId.value = material.mid;
@ -712,6 +718,15 @@
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
}
}
});
@ -803,6 +818,14 @@
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(data.unit, "-1"));
var unitList = data["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
}
}
@ -872,6 +895,15 @@
form.render();
}
form.render();
var unit = $("#unit" + idNumber);
unit.empty();
$("#unit" + idNumber).append(new Option(material.unit, "-1"));
var unitList = material["splitInfoList"];
for (let i = 0; i < unitList.length; i++) {
$("#unit" + idNumber).append(new Option(unitList[i].newUnit, unitList[i].newUnit));
}
form.render();
} else {
// 如果没有对应关系
layer.msg("对于编码:" + result + ",并未发现对应的物料", {
@ -961,7 +993,32 @@
})
}
})
}
};
form.on('select()', function (data) {
let elem = data.elem; //得到select原始DOM对象
let elemId = elem.id;
if(elemId.indexOf("unit") === 0){
// 如果进行选择的是计量单位
let id = elemId.split("unit")[1];
let mid = $("#mid"+id).val();
let unit = data.value;
let req = {};
req.newUnit = unit;
req.mid = mid;
$.ajax({
url:"/split/calcPriceForSplit",
data:JSON.stringify(req),
dataType:"json",
type:"post",
contentType: "application/json;charset=utf-8",
success:function (res) {
let data = res.data;
$("#price"+id).val(data);
}
});
}
});
})
</script>

2
target/classes/templates/pages/application/form-step-look.html

@ -40,7 +40,7 @@
</tr>
<tr>
<td>计量单位</td>
<td id="munit" th:text="${record.getMunit()}">外芯仓库</td>
<td id="airunit" th:text="${record.getAirUnit()}">外芯仓库</td>
</tr>
<tr>
<td>数量</td>

2
target/classes/templates/pages/depository/table-in.html

@ -141,6 +141,8 @@
{type: "checkbox", width: 50},
{field: 'aircode', width: 150, title: '提交编码', sort: true},
{field: 'mname', width: 150, title: '物料名称'},
{field: 'mversion', width: 150, title: '规格型号'},
{field: 'airUnit', width: 100, title: '计量单位'},
{field: 'mcode', width: 150, title: '存货编码'},
{field: 'quantity', width: 150, title: '数量', sort: true},
{field: 'price', title: '金额', minWidth: 150, sort: true},

6
target/classes/templates/pages/depository/table-stock.html

@ -140,13 +140,13 @@
{field: 'code', width: 200, title: '存货编码'},
{field: 'typeName', width: 200, title: '物料类型'},
{field: 'quantity', width: 200, title: '数量', sort: true},
{field: 'unit', width: 200, title: '计量单位'},
{field: 'depositoryName', width: 200, title: '仓库名称'},
{field: 'depositoryCode', width: 200, title: '仓库编码'},
{title: '所处库位', width: 200, templet: '#selectManager', align: "center"},
{field: 'warningCount', width: 200, title: '待过期数量', sort: true},
{field: 'price', title: '单价', width: 200, sort: true},
{field: 'amounts', title: '总金额', width: 200, sort: true},
{field: 'unit', width: 200, title: '计量单位'},
{field: 'texture', width: 200, title: '材质',},
{title: '操作', minWidth: 250, toolbar: '#currentTableBar', align: "center"}
]
@ -169,8 +169,8 @@
}
}
//
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i+1) + ")").children()[8];
// 所处库位
var placeCodeItem = $("[lay-id='currentTableId'] tr:eq(" + (i+1) + ")").children()[9];
var aItem = placeCodeItem.childNodes[0];
for (let k = 0; k < placeCode.length; k++) {
if(placeCode[k] !== ""){

Loading…
Cancel
Save